Page 1 of 1

cant display angle of an actor???

PostPosted: Sat Apr 02, 2011 7:50 am
by sonicfire
hi folks!

this oneĀ“s baffling me:
Code: Select all
//debug text actor, draw event
debug1 = player.angle;
sprintf(text, "angle %i", debug1);


my player object rotates (angle+=newangle) but the readout doesnt work. why?
it always shows "angle 0" on screen?

Re: cant display angle of an actor???

PostPosted: Sat Apr 02, 2011 7:51 am
by sonicfire
player actor draw event:
Code: Select all
angle+=newangle;
newangle+=0.1;
animpos = (angle*360)/nframes;

Re: cant display angle of an actor???

PostPosted: Sat Apr 02, 2011 8:48 am
by skydereign
What is happening is angle is a variable determined by movement, kind of like the velocity variables and previous variables. That is to say, if you have a draw event with x+=5, the actor's xvelocity will be 5. But, with the case of angle, if the actor is not moving, then it will be automatically set to zero. So, at the end of the draw script, the angle is set to zero.

Now I didn't test with an actual rotating animation, but one of two things is happening. Either, due to the weird properties of the draw event, the angle value is remembered in that event only, or the more likely case, as your newangle increases, it is setting the angle to the value of newangle accounting for your rotating (despite the setting to zero).

This should fix it.
Code: Select all
angle+=newangle;
newangle+=0.1;
animpos = (angle*360)/nframes;
sprintf(debugText.text, "angle %i", (int)angle);

Re: cant display angle of an actor???

PostPosted: Sat Apr 02, 2011 9:33 am
by sonicfire
thanks! you could be right about this movement vs no movement thing. i tested your way, still weird and not quite right somehow.
will do further tests and see what happens when my player object (ship) is actually moving :) thank you!

Re: cant display angle of an actor???

PostPosted: Sat Apr 02, 2011 9:36 am
by sonicfire
ok, you were right, when i applied some movement to my actor (yvelocity for example) then the angle was reporting correct values. :)

EDIT: oops, and i mixed up
Code: Select all
animpos = (angle*360.0)/nframes;


it should be:
Code: Select all
animpos = (angle/360.0)*nframes;