Face direction of player

Rawr

  • Posts: 85
No, not in 2D.
I want the actor to switch animations according to the player's position-either on its left or its right.

How?



Thanks.

Sunflower

  • Posts: 591
Code: [Select]
for each object of type [Player]
  if < [x of Self] > [x of [the actor]] >  //player is on the left
    switch animation to [as animation [Face Left]] for Self
  if < [x of Self] < [x of [the actor]] > //player is on the right
    switch animation to [as animation [Face Right]] for Self
Both "greater than" and "smaller than" blocks ([ 0 ] > [ 0 ]) are to be found in Numbers & Text >> Compare.
"for each actor of type" and "the actor" are in Scene >> Actors
"switch animation to" and "as animation [anything]" are in Actor >> Draw. Of course, in "as animation [anything]" you're supposed to put the name of animation.

Rawr

  • Posts: 85
Hmm...is that supposed to be a scene behavior, or an actor one?

Rawr

  • Posts: 85
Wait...you kidding me bro?
If it's an actor behavior...then I can't set the attribute for the actor to face...
If it's a scene behavior...There's no such thing as "x of self". Eben if you try to replace that with an attribute, it will only apply to one actor.
And even worse, I tried both, both didn't work, and both lag like hell.



Now wut.

coleislazy

  • *
  • Posts: 2607
This is an actor behavior to be attached to your enemy. You don't need to set an attribute to the value of the player. The "for each actor of [type]" block has a block called "the actor" directly below it which is the value of the actor the iterator is on. I'm assuming you only have one actor of your player's type in the scene, so this will always represent the player.

Also, I don't think Sunflower is a "bro".

Rawr

  • Posts: 85
This is an actor behavior to be attached to your enemy. You don't need to set an attribute to the value of the player. The "for each actor of [type]" block has a block called "the actor" directly below it which is the value of the actor the iterator is on. I'm assuming you only have one actor of your player's type in the scene, so this will always represent the player.

Also, I don't think Sunflower is a "bro".
Wait...then I can't set the "x of [player]" attirbute.

Also, the "bro" refers to the design mode interface :P

coleislazy

  • *
  • Posts: 2607

Rawr

  • Posts: 85
Oh that...got it.
I'll go try that nao. Thanks.

EDIT: Yup! It works! Thanks! Also found out how to set delay on the reaction, use it to toggle other actions and stuff. That helped a lot on my game design. Thanks again.

« Last Edit: August 28, 2011, 04:02:49 am by Rawr »