The Daily Click ::. Forums ::. Klik Coding Help ::. Physics engine help needed
 

Post Reply  Post Oekaki 
 

Posted By Message

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
23rd September, 2013 at 23/09/2013 19:04:00 -

Hi,

For weeks now I have been trying to create a good top-down car physics engine. For a car movement I'm using:
- Car.x = Car.x + (Cos(Car.angle) * Car.speed)
- Car.y = Car.y - (Sin(Car.angle) * Car.speed)
This formula is good for me when I'm driving at low speed (less that 30% of max speed). But when I exceed 30% i would like to change to space movement:
- Velocity.x = Velocity.x + (Cos(Ship.angle) * Ship.acceleration)
- Velocity.y = Velocity.y - (Sin(Ship.angle) * Ship.acceleration)

How can I change it or how can implement between this two movements?

Thx for reply

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49567

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
24th September, 2013 at 24/09/2013 02:43:12 -

Store two angles. Store the direction the car is facing and it's travel direction.

When the speed is less that 30% have the travel direction = direction car is facing.
When the speed is greater than 30% make the travel direction lag behind the direction the car is facing.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th September, 2013 at 24/09/2013 18:20:03 -

Yeah, it's not exactly realistic, but UrbanMonk's solution is a pretty good way of doing simple arcade style car handling. If you need something more sophisticated than that, it's likely to get very complicated, very fast (especially once cars start colliding with things).

 
n/a

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
24th September, 2013 at 24/09/2013 20:23:34 -

Ok, I will try that .

Thx for reply guys

 
n/a
   

Post Reply



 



Advertisement

Worth A Click