Forum rules - please read before posting.

have actionscript based on the Player direction?

edited August 2014 in Technical Q&A
hi! 
hi have a question about trigger...
i want to make visibile an object(with "remember visibility") when my player enter in a "trigger" but only if the direction of my player are "walking_L" ( this becouse i want active that, only when the player enter by left side, and not when are by right side.)

is this possible or i have to build my own code?

Comments

  • edited August 2014
    Hi!...

    I don't think it's possible to ask the direction of a character right now, maybe if there is a way using mecanim... and obviously with custom code everything is possible, but you can achieve this using triggers and a local variable...  to know if the character enters by the left side you could just use 2 triggers, side by side...

    Character -> [Left Trigger][ Visibility Trigger ]

    The Left Trigger could call an actionlist that activates a flag... EnteredLeft = true... and if entering the Visibility Trigger you could ask if EnteredLeft is true before making that object visible. Remember to restart EnteredLeft = false, every time you get out the Visibility Trigger if you want to do that again.

    For full directions... you could have 3 more triggers (or a big one that covers the rest of triggers) like a cross :

    [                                           Up -> EnteredLeft = false                                           ]
    [Left -> EnteredLeft = true] [Visibility -> Is EnteredLeft?] [Right -> EnteredLeft = false]
    [                                        Down-> EnteredLeft = false                                           ]

    Hope it helps... :)


  • edited August 2014
    Hi, MaaS,
    thank you for the reply.

    the problem are that i make a 2d Game. in the specific i have a scene with a 2D simple corridor that you can enter from the left and from the right side.
    and i want to make an object visible only when my players are watching in the opposite direction of the object(be shoulders to that  object)

    in this case the object are at center of the scene, and i divide the scene in two triggers. Left and Right.
    The problem are that i can not know if the players are in the opposite direction or not to the object when it enter in one of them, that is because i needed to know what direction the playr are ^^ when are inside the trigger with "continuous" state active.

    but i think there is no way to check that at this time.

    ^^

    iif you have in  mind something let me know ^^ 




  • I'm failing to visualise your problem - a screenshot with annotations would help a lot.

    In script, you can get a 2D character's direction with the NPC / Player script's GetSpriteDirection () function.  Left will return "_L", right "_R" and so on.
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.