cant display angle of an actor???

Non-platform specific questions.

cant display angle of an actor???

Postby sonicfire » Sat Apr 02, 2011 7:50 am

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?
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: cant display angle of an actor???

Postby sonicfire » Sat Apr 02, 2011 7:51 am

player actor draw event:
Code: Select all
angle+=newangle;
newangle+=0.1;
animpos = (angle*360)/nframes;
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: cant display angle of an actor???

Postby skydereign » Sat Apr 02, 2011 8:48 am

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);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: cant display angle of an actor???

Postby sonicfire » Sat Apr 02, 2011 9:33 am

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!
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: cant display angle of an actor???

Postby sonicfire » Sat Apr 02, 2011 9:36 am

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;
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest