Forum rules - please read before posting.

Run Actionlist ONLY when object is visible in camera?

I have a 2D game with a 2D Drag Camera and no Player character. It's a POV game where the user is the character, so the user navigates the scene by dragging the mouse (or touch) to scroll the graphics.

How can I run an Actionlist when the 2D Drag Camera "sees" an object. I would like to trigger an animated Game Object but only once the Game Object has been in the Camera viewport for a certain amount of time. I have Remember Visibility component on my animated Game Object but can't figure out where to put the ActionList that will be triggered.

Comments

  • The Remember Visibility is only for dealing with the enabled state of a sprite or mesh - not for whether its in view of the current camera or not.

    This would best be done with a custom script that reads if the object's renderer is in view of the camera:


    And then run an ActionList programatically by invoking its Interact() method.

    However, if you really wanted to avoid scripting, you could possibly try the following:

    1) Attach a Trigger2D to the Camera as well as a Rigidbody2D (set to Kinematic so it doesn't move improperly)
    2) Attach a 2D Collider to the sprite object, and configure the Trigger to only detect this object.
    3) Make a separate Cutscene that animates the object, and give it a Start delay (s) in its properties.
    4) Make the Trigger react to "On Enter".  Give it a single ActionList: Run to run the ActionList in #3.
    5) Add another Trigger below, that reacts to the same sprite, "On Exit", and have it run a single ActionList: Kill Action to kill the ActionList in #3.
  • Oh yes! The Trigger solution is perfect.
    Thank you!
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.