Enemy Faceup to player?

takao

  • Posts: 10
im newbie, i wanna asking how to make enemy faceup to player?
i make atribute *player X and enemy X

i put that in behaviour
when create : set player X to, X of : self (for player)

when create : set enemy X to,X of : self (for enemy)
and i put this behaviour on enemy

always
if : player X <= enemy X
switch animation to "right" for : self

if : player X>= enemy X
switch animation to "left" for : self

i dont se my enemy face up to my player, why??

i need help here T__T


yoplalala

  • *
  • Posts: 1632
When you create your attributes   player X and ennemy X you set it and never modify it.

if at first the x of player is 5 , and you set you player X to x of player then  player X=5.
Even if x of player changes .

You must put the set player and the set ennemy x in the always block too.

When you start programming, if you see there's a mistake,  put some print blocks ( for example , here, print player X), it will you find where is your mistake.

takao

  • Posts: 10
then how about X for enemy?

do you have tutorial for my problem?? :(

yoplalala

  • *
  • Posts: 1632
It 's the same, put it in a always block.
Could you put an screenshot of the code ? It will be easier to guide you :)

takao

  • Posts: 10
Sure, here
1) when create  (i put this on player)
2) when create (i put this on enemy)
3) always (  i put this on enemy)

 i hope you can help me :(

yoplalala

  • *
  • Posts: 1632
Did you try by the changing the when created by an always block ? ( for 1) and 2) ) ?

takao

  • Posts: 10
i do, but not work :(
any another solution?
or you can give me the link for tutorial like this problem??

yoplalala

  • *
  • Posts: 1632
Ok I'll try later to send you a code I will test

yoplalala

  • *
  • Posts: 1632
You just to put everything in the always block. It works i've tested it.
Here is the ennemy block  (the ennemy is the monkey, the player is the croc)

Are you sure your animation name is right ?

takao

  • Posts: 10
oh yes you right!!!.
thankyou thankyou thankyou >o<
nobody care about newbie. thankyou >////<