(Realistic) Sliding!?

El-Sevio

New Member
Reaction score
0
Yeeah, SUP G

So what I'm trying to do is create a realistic 'sliding' movement style.

A 'car on ice' type situation. And realistic, not like the maze games from war3 where you would have maneouver between objects with complete control over steering, but rather one where you try to steer but you would slide outwards when taking corners, etc

So basically its a question of acceleration!

At the moment:
JASS:
real acceleration = 0.01 (constant)
real x velocity
real y velocity
unit u
real x
real y
point d

if the x of u < the x of point d then
set x velocity = x velocity + acceleration
else
set x velocity = x velocity - acceleration

and then repeat for Y values

and then move unit to his location + x velocity + y velocity

(the above written correctly)



This gives a rough simulation of what I want, he accelerates towards a point and curves out on some corners, but its far from perfect.

So please, people of the interweb may you help me with this functionn?

What am I doing wrong, good sir? Should I be using vectors for acceleration? Or is the effect achieved in a completerly different way?!
 

onisagi

New Member
Reaction score
6
Instances in which you'll need vector acceleration?
- When you have external forces that can come in a variety of directions. Wind. Collision.
- Your "car" can accelerate towards any direction at any given moment.
- You just want your code to be easier to look at by keep everything neatly separated.

Some tips:
- You wouldn't need that if-statement if your acceleration can be negative. Adding a negative acceleration to your velocity is the same as subtracting acceleration.
- you need a rolling friction force/acceleration to slowly stop your car after your applied an acceleration and get the car moving. This force ceases the moment your car velocity becomes zero, so that it doesn't suddenly roll backwards seemingly defying the laws of physics D:!
- I'll assume you have the portion of applying acceleration from user input. Try to get it to move in constant velocity after you let go of input, then add in rolling friction to make it stop overtime.
 

El-Sevio

New Member
Reaction score
0
Thanks for your comments

Ok so I've revised my code, and I've got a somewhat desired effect. At the moment I set where you right click-move as a destination, and essentially have the unit accelerate towards that point.

Some problems I'm having so far: The car has too little control over movement - the orbiting effect, or sliding is too much at the moment and acts more like a satelite in space rather than a car who can drive on the road

Is this due to the lack of both the thrust force (engine) and the friction force from the road?

How to implement these effectively?
 

onisagi

New Member
Reaction score
6
also "google" some more sites if you need more help. This kinda stuff is littered all over the web.

The orbitting is probably because you have no friction to stop the car. Once you have friction, it should fix itself.

But isn't it strange to click to accelerate to a point? you could make it so the car just moves towards the direction clicked rather than the point, and the click distance from your unit effecting how fast your car moves to the point? Will this work out for your purposes?
 

El-Sevio

New Member
Reaction score
0
Hey thanks, that tutorial was amazingly helpful. And yes, friction + engine power solved everything. Thanks guys.
Hmm, you can't provide +rep to more than one person?
 

onisagi

New Member
Reaction score
6
give it to formerself, he actually gave you a specific answer. xD

Is it 1 per day? iono either...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top