Copy link to clipboard
Copied
Hey,
Just wondering how I can determine what coordinates my car needs to when I press up on my keyboard relative to the directions the car steers to.
Basically, when I steering the car I want it to still go forward after I've steered.
Here's the function I have prepared already:
public function actions(event:Event):void { | ||||
if (upKeyDown) { | ||||
} | ||||
if (rightKeyDown) { | ||||
this.rotation+=steering; | ||||
} | ||||
if (leftKeyDown) { | ||||
this.rotation-=steering; | ||||
} | ||||
} |
Look for the line where its says:
velocityX = Math.sin (this.rotation * Math.PI / 180) * speed;
this velocityX (and velocityY) is used in the enter_frame function to set the cars position on stage
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I've already been to that website, my problem was I don't understand where those variables were being used on the car x and y coordinates. I can only see them being set and not used. Care to explain how they are being used on the car object?
Thanks for the reply.
Copy link to clipboard
Copied
Look for the line where its says:
velocityX = Math.sin (this.rotation * Math.PI / 180) * speed;
this velocityX (and velocityY) is used in the enter_frame function to set the cars position on stage
Find more inspiration, events, and resources on the new Adobe Community
Explore Now