Legacy GM [SOLVED] Rotation problem

O

Ole Marius Andersen

Guest
Hello! I'm experiencing some issues trying to rotate an object.

I have it so the rotation is set when it's created, and then it rotates based on the direction it is facing.
All of that is working fine, except for one little problem. The rotation adjustment that happens when it is
created is always one frame late or so. It points to the right (0 rotation) for a frame, and then it updates to whatever the correct direction is.

Anyone got any ideas as to what may be the problem? I'll attach the project for easier helping.

http://host-a.net/u/Jimmy/arrowPhysics.gmx.zip
 

PNelly

Member
Not everyone has access to GM handy, or usually wants to go to the trouble of downloading a project file. If you paste your code for rotating your image you'll be more likely to get good help more quickly
 
Not easy to tell without seeing your code. However, sometimes these problems can be solved by putting the rotation updates in the End Step event. But that's just a shot in the dark for now.
 
X

Xenon

Guest
I jumped the gun thinking you were talking about 3d rotations... Anyways...
I download your project, crashed on startup and i couldn't tell you why, but i read your code and you are trying to rotate a 2d sprite using image angle and point direction, i am assuming you want to rotate the arrows image angle.

I think that if you set the direction with something like
image_angle = point_direction(x, y, mouse_x, mouse_y);
in the CREATE EVENT of OBJ_ARROW then it should update the image angle immediately once its created, instead of updating it in the STEP EVENT of another object.
 
O

Ole Marius Andersen

Guest
I jumped the gun thinking you were talking about 3d rotations... Anyways...
I download your project, crashed on startup and i couldn't tell you why, but i read your code and you are trying to rotate a 2d sprite using image angle and point direction, i am assuming you want to rotate the arrows image angle.

I think that if you set the direction with something like
image_angle = point_direction(x, y, mouse_x, mouse_y);
in the CREATE EVENT of OBJ_ARROW then it should update the image angle immediately once its created, instead of updating it in the STEP EVENT of another object.
Yes, this worked! I originally set the "direction" of arrow_obj instead of setting "image_angle" in the create event. Thinking it would work because I have "image_angle = direction" in the step event, but changing it to "image_angle" in the create event did the trick!

Thanks for all the help, everyone! Next time I will be sure to include the code directly in the post instead for easier helping.
 
Top