This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-11 06:17:12

northmeister
Scratcher
Registered: 2011-07-12
Posts: 1000+

Car Turning Physics Engine

I need a realistic car turning engine for a physics engine I'm tweaking for one of my games. When the arrows are pressed, it changes a turn velocity and stuff. I have a script for the speed as well, changing when the arrows are pressed. For the turning, I've tried to make it just turn the turn velocity degrees, but then that means you could turn the car when it's stopped, which is wrong. I've tried to make it turn turn velocity / (50 - speed) which means the higher the speed, the more it turns, which means it doesn't turn when it's stopped, but it does when you're driving, but that didn't work either.

I just need a realistic turn engine, and everything I've tried doesn't work. I'll credit the person who can find a good engine in the game. Thanks  smile


http://i48.tinypic.com/5a25g5.png

Offline

 

#2 2012-04-11 08:13:46

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Car Turning Physics Engine

challenge accepted  big_smile
Let me try and do some experimenting.


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#3 2012-04-11 08:32:18

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Car Turning Physics Engine

if your just turning by velocity degrees (like the script below, right?), then with a velocity of zero, you wouldn't be able to turn, so how can you turn when you're stopped?  Is there a difference between the speed and velocity variables?

turn cw (velocity) degrees


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#4 2012-04-11 09:05:06

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Car Turning Physics Engine

Here's a first, quite simple attempt:
http://scratch.mit.edu/projects/JSOlabs/2461801

It works, but you can make really sharp turns also when driving fast which is kind of odd. Maybe I can still fix that.


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#5 2012-04-11 13:38:23

northmeister
Scratcher
Registered: 2011-07-12
Posts: 1000+

Re: Car Turning Physics Engine

MoreGamesNow wrote:

if your just turning by velocity degrees (like the script below, right?), then with a velocity of zero, you wouldn't be able to turn, so how can you turn when you're stopped?  Is there a difference between the speed and velocity variables?

turn cw (velocity) degrees

I'm trying to make it turn depending on the speed, so that if the car is going faster it turns in a wider circle, and if it's going slower it turns in a tighter circle, but doesn't turn when stopped. So yes, there is a difference between the speed and turn velocity variables.


http://i48.tinypic.com/5a25g5.png

Offline

 

#6 2012-04-11 13:41:03

northmeister
Scratcher
Registered: 2011-07-12
Posts: 1000+

Re: Car Turning Physics Engine

JSO wrote:

challenge accepted  big_smile
Let me try and do some experimenting.

Thanks  big_smile


http://i48.tinypic.com/5a25g5.png

Offline

 

#7 2012-04-11 14:01:18

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Car Turning Physics Engine

northmeister wrote:

MoreGamesNow wrote:

if your just turning by velocity degrees (like the script below, right?), then with a velocity of zero, you wouldn't be able to turn, so how can you turn when you're stopped?  Is there a difference between the speed and velocity variables?

turn cw (velocity) degrees

I'm trying to make it turn depending on the speed, so that if the car is going faster it turns in a wider circle, and if it's going slower it turns in a tighter circle, but doesn't turn when stopped. So yes, there is a difference between the speed and turn velocity variables.

Ah, I understand now.  In one of my projects, I did something similar using this:

turn cw ((12)/([sqrt v] of (speed))) degrees
Are you looking for a formula like that?


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#8 2012-04-11 15:47:52

northmeister
Scratcher
Registered: 2011-07-12
Posts: 1000+

Re: Car Turning Physics Engine

MoreGamesNow wrote:

northmeister wrote:

MoreGamesNow wrote:

if your just turning by velocity degrees (like the script below, right?), then with a velocity of zero, you wouldn't be able to turn, so how can you turn when you're stopped?  Is there a difference between the speed and velocity variables?

turn cw (velocity) degrees

I'm trying to make it turn depending on the speed, so that if the car is going faster it turns in a wider circle, and if it's going slower it turns in a tighter circle, but doesn't turn when stopped. So yes, there is a difference between the speed and turn velocity variables.

Ah, I understand now.  In one of my projects, I did something similar using this:

turn cw ((12)/([sqrt v] of (speed))) degrees
Are you looking for a formula like that?

That looks good, but I need the 'turn velocity' variable in there somewhere  wink

Last edited by northmeister (2012-04-11 15:48:22)


http://i48.tinypic.com/5a25g5.png

Offline

 

#9 2012-04-11 15:53:08

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Car Turning Physics Engine

northmeister wrote:

MoreGamesNow wrote:

Ah, I understand now.  In one of my projects, I did something similar using this:

turn cw ((12)/([sqrt v] of (speed))) degrees
Are you looking for a formula like that?

That looks good, but I need the 'turn velocity' variable in there somewhere  wink

set [turn velocity v] to ((12)/([sqrt v] of (speed)))
turn cw (turn velocity) degrees
Hows that?


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#10 2012-04-11 16:02:19

northmeister
Scratcher
Registered: 2011-07-12
Posts: 1000+

Re: Car Turning Physics Engine

MoreGamesNow wrote:

northmeister wrote:

MoreGamesNow wrote:

Ah, I understand now.  In one of my projects, I did something similar using this:

turn cw ((12)/([sqrt v] of (speed))) degrees
Are you looking for a formula like that?

That looks good, but I need the 'turn velocity' variable in there somewhere  wink

set [turn velocity v] to ((12)/([sqrt v] of (speed)))
turn cw (turn velocity) degrees
Hows that?

That looks really good  big_smile  I think I have mine almost figured out, if I get stuck again I'll probably use yours or/and JSO's  wink


http://i48.tinypic.com/5a25g5.png

Offline

 

#11 2012-04-11 16:16:08

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Car Turning Physics Engine

northmeister wrote:

That looks really good  big_smile  I think I have mine almost figured out, if I get stuck again I'll probably use yours or/and JSO's  wink

Oops, that's probably not what you're looking for after all, sorry (when you travel slowly, your turning speed speeds up.  When you're not moving, you can turn "12/0" degrees x(.  This one should work xD

set [turn velocity v] to ((2) * ([sqrt v] of (speed)))


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#12 2012-04-11 17:35:36

northmeister
Scratcher
Registered: 2011-07-12
Posts: 1000+

Re: Car Turning Physics Engine

MoreGamesNow wrote:

northmeister wrote:

That looks really good  big_smile  I think I have mine almost figured out, if I get stuck again I'll probably use yours or/and JSO's  wink

Oops, that's probably not what you're looking for after all, sorry (when you travel slowly, your turning speed speeds up.  When you're not moving, you can turn "12/0" degrees x(.  This one should work xD

set [turn velocity v] to ((2) * ([sqrt v] of (speed)))

Ok, the new one looks similar to one I used already  tongue


http://i48.tinypic.com/5a25g5.png

Offline

 

Board footer