Page 1 of 1

Does GE have this feature?

PostPosted: Thu Feb 10, 2011 8:55 pm
by jb15
I'm trying to make a car go around a path. I have two questions:

1. Is there a way I can make the car rotate automatically, to make it look like it's actually driving around the track?

2. Is there a way I can control the speed? (For example, connect the path speed to "carspeed" variable. When key space is down, make "carspeed" = "carspeed" + 1. When key b is down, make "carspeed" = "carspeed" - 1).

Is this doable?

Re: Does GE have this feature?

PostPosted: Fri Feb 11, 2011 1:51 pm
by Hblade
No, GE does not support rotation by coding, however you can have your car rotate animatedly with 359 animation frames, then have your movement xvelocity and yvelocity based on the angle. For example:

animpos=angle;




When turning the car, do something like this:
angle++;



Now for the movement code:
Code: Select all
directional_velocity=5;



This will make him move 5 pixels per frame in the angle the car is in. I could give a full detailed example if you want.

Re: Does GE have this feature?

PostPosted: Fri Feb 11, 2011 9:57 pm
by jb15
I'd really appreciate an example file! I'm brand new to GE, and don't really know what I'm doing... :)

Re: Does GE have this feature?

PostPosted: Sat Feb 12, 2011 8:05 pm
by Hblade
Well see the thing is I don't have GE currently installed on this comp :( Hmm try this: make the car rotate with 24 frames

Now for the angle control

Code: Select all
angle=animpos*24;


then, on KeyDown (The go button)

Code: Select all
directional_velocity=5;


That should do it xD Oh, and if the car goes backwards, then try changing the angle code to this:
Code: Select all
angle=-animpos*24;

Re: Does GE have this feature?

PostPosted: Wed Feb 16, 2011 2:58 am
by jb15
Thanks for the reply. It's not working for me, though. (By that I mean I see no difference between before and after I coded). The car still just faces the right constantly. Any tips? Help?

Re: Does GE have this feature?

PostPosted: Wed Feb 16, 2011 8:04 am
by schnellboot
hm.. do you have the rotating animation?

Re: Does GE have this feature?

PostPosted: Wed Feb 16, 2011 3:41 pm
by jb15
I don't really know what you mean... Do you mean I need to make separate animations, with the car facing the different directions? I that's what you mean, how would I do that? Are there any tools that could speed up the process?

Re: Does GE have this feature?

PostPosted: Wed Feb 16, 2011 3:49 pm
by schnellboot
yes you do
http://game-editor.com/forum/viewtopic.php?f=1&t=9418&p=65783
this is what you need thanks to DST