Rotational direction using cos and sin
NacMacFeegle
Member Posts: 11
Using keyboard input I have achieved rotational and directional movement forward using the cos and sin functions as follows.
self.position.x+*cos(self.rotation)
self.position.y+*sin(self.rotation)
However if I take either one of the lines out it still works.
Can anybody help to point me in the direction to achieve both forward and backward rotational movement using the keyboard as the input device?
Many thanks
Regards
Chris
self.position.x+*cos(self.rotation)
self.position.y+*sin(self.rotation)
However if I take either one of the lines out it still works.
Can anybody help to point me in the direction to achieve both forward and backward rotational movement using the keyboard as the input device?
Many thanks
Regards
Chris
Comments
For example, are you doing Change Attribute self.position.x to self.position.x*cos(self.rotation)? You listed the operators +* which isn't making sense to me.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
On key down
Do
Move
Move in direction (equation goes here)
Move in direction (equation goes here)
What the +* should do is add the multiplied result.
Thanks
I'm not trying to be a pain... just trying to understand how you have it set up and then help you out.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Many thanks
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I have zipped up how far I have got, what you should end up with is a square that rotates using the arrow keys left and right, moves forward using the up arrow key in the direction it is now pointing. It’s the back arrow key I can’t get working; I think the process is described as negating.
https://www.dropbox.com/s/mwf0s7eldphj73k/qk.zip
Thanks
Try this:
http://www.mediafire.com/?44w9vhpmjbzsfym
Chris