Forum rules - please read before posting.

Instantiate a Trigger 2D that can run a actionlist

I face a situation that, I have to randomly generate some obstacles at random positions. And I want to generate some obstacles that has a Trigger 2D in front of it, so that when the player is running towards such obstacle and steps into the Trigger, the obstacle will run certain animation.

I was planning to use GameObject.instantiate to create both the obstacle and Trigger, but then I realize I cannot instantiate a Trigger with the correct actionlist. Even if I put the ActionList of the Trigger as an ActionList asset, I cannot find a way to change the action parameters (e.g. which object to animate) of the ActionList asset by script.

How may I achieve such effect?

Comments

  • Have it reference an ActionList asset, and then attach the Set Trigger Parameters component, which lets you define values for all parameters associated with the asset.

  • Thanks. But how may I set the parameters by script? I don't know what to do after GetComponent<AC.SetTriggerParameters>().

  • It's a closed component - it's intended to be used from its Inspector, only.

    Are the object parameter values you want to assign part of the Trigger prefab? See the new Logic prefabs tutorial video for a guide on how you can create parameter-based Trigger prefabs.

  • I was trying to use 1 prefab to play different animations with different parameters. I worked around by using different prefabs with the parameters set to different animation clips.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.