Jump to content
Sign in to follow this  
Koning Julien

Spawn layer script

Recommended Posts

Hi all,

 

I'm trying to activate a layer through script. The layer is called "Layer2" in the editor and has Activation Type "ON_TRIGGER_ACTIVATION".

 

I have a trigger that has an "OnActivate" script. In this script I would like to tell the game to activate "Layer2" (and subsequently all entities below it). I currently have this code:

 

class Trigger1_Class: SCR_FactionControlTriggerEntity 
{
	override void OnActivate(IEntity ent)
	{
		SCR_HintManagerComponent.GetInstance().ShowCustomHint("Trigger fired", "Success", 15); //The hint pops up when the trigger fired, which proves the trigger is set up correctly
		IEntity nextLayer = GetGame().GetWorld().FindEntityByName("Layer2"); //The script gets Layer2; but now how do I activate it?
	}

};

Any help is greatly appreciated!

Share this post


Link to post
Share on other sites

Do you have any update on this ?

 

I tried too but I did not find any solution.

 

Here is my guess :

 

GenericEntity targetEntity = GenericEntity.Cast(GetGame().GetWorld().FindEntityByName("Layer1"));

targetEntity.Activate();

 

 

But it's not working.

Share this post


Link to post
Share on other sites

Try to use flags.

targetEntity.SetFlags(EntityFlags.ACTIVE, false);

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×