TO EVERYONE WITH BOUNCY SUSPENSION: use the spring formula with dampening equation: F = -kx - bv where k is the "tightness" of the spring, x is how much the spring is compressed, b is the coefficient of damping, and v is the velocity of the point at which you are applying the suspension force. For clarification, damping is a spring resisting change, which helps stabilize suspension. Here is a snippet of my code: float distance = SuspensionDistance - hit.distance; //This gets the distance the "string was pushed" in the context of this implementation //hit.distance is the raycast's distance to the hit point float force = -SuspensionStrength * distance + (SuspensionDamping * carBody.GetPointVelocity(corner).y); //the -bv had to be inverted for damping to work. //SuspensionStrength is a constant that represents "k", and SuspensionDamping is a constant that represents "b".
many mistakes here, it s not distance that u should calculate, but compression, so compression = 1-(hitDistance/suspensionDistance) - And global spring formula to get the force should be (compression * suspensionStrengh) - (SuspensionDampling*Zvelocity) (yeah UE is Zup) - Add to that that considering the local space physX calculations, suspensionStrengh is around 100 000 constant value, dampling around 100 to get a clean stable system
Thank you so much, I loved this video. Short, crisp, beautifully explained and the best part, completely engine independent. But I think you should add tags like Vehicle, Physics, Mechanics, and also common engine names like Unreal and Unity. This is what I've been looking for but it never showed up in search results...finally had someone in the Godot Forum recommending this to me.
This is so helpful that I will only need about 5 years of studying forces and vector math to get this to work the way you have. :D I got the box bouncing up and down and then hovering nicely with some dampening. However there are so many things that you didn't even mention that it will blow any beginner's mind and 500 hours away. Have a good day :)
This is very impressive and insightful. I really appreciate videos like this that don't just "show" but also explain how your achieving your results. Very cool stuff. Hope to see more of these in the future!
That was a very good instructional video. Good build order of concepts, each explained with precision, and without getting too wordy. I hope you are going to continue making these because you're very good at them!
This is awesome, thanks so much for making this video! It's very inspiring to see how you guys made your game and then also teach the principles in a very detailed manner, starting from the ground up. This is great video I know I'll keep coming back to when I'm working on vehicles!
Solid video! I am attempting to make a game with a huge amount of small cars (think, like, 100's of swarming micromachines) and your vid greatly helped me implement the car "drifting" physics I was looking for! I avoided the suspension, and simply made the base of each car a friction-less box (collider). But the rest? SO helpful! Kudos!
I know this video is quite old, but the information is incredible valuable. Are there any additional resource available that would dig deeper in to the blueprints so that I may learn? This is incredibly close to what I am trying to achieve and I am still learning - and I have a LOT to learn. Did you ever create a more in-depth look at the system(s) you created? Wonderful video - and thank you very much.
Hi, thank you for the very informative video. Something that most game companies do not do. I am experience the problem where the car takes off depending on where it's looking, For example, I jump off a ramp, I nose dive since it's launching off/on to the ground.
+moynul hussain You could probably disable the acceleration when the car is in mid air (if all rays are not hitting the ground). You could also divide the car's acceleration with the local pitch rotation of the vehicle, so when the car climbs hills, the steeper the hill, the less acceleration. I haven't tested this, so I'm not 100% sure if this would work. Also, it's a good idea to clamp the car's acceleration values to limit the max acceleration, so when you go downhill it doesn't multiply the acceleration so much.
This is a very useful vid. Thanks for doing it. Would love to see a tutorial for building vehicles this way, including wheel animation. Not fully satisfied with Unreal's default vehicle options.
So good! Thank you so much for sharing :) How does one calculate the surface angle from the raycast hit? (so that the car doesnt acclerate into the ground or air when the body isn't level with the ground)?
I know its old comment but for those who want an anwser for that I did it like that Take the dot product of velocity and right vector, then multiply it by right Vector, then multiply it by -1 and number you like (the higher number the higher friction) and plug it to add force on tick. (Only when on the ground)
This video was super awesome and informative, and I built my arcade racing physics from it! As an aside, for me, just having compression*thrust wasn't sufficient for the suspension, if you have issues with bouncing/oscillation a PID system can instead handle the force of each spring, P being a product of the error (goalDisplacement-displacement) D being the differential (Velocity of the spring compression) and I being the integral (Accumulating sum of the errors in each tick).
CHARACTERNAME what physics system did you use? I’m watching this and I see he said he didn’t use unreals physics system but haven’t they upgraded to nvidia physx? Would all of this workin inside of there
I love this approach! I solved the suspension part but it generates a huge 'drag force when I want to move the wehicle forward...if I dont apply 'thrust force' to it, the wehicle slows down super fast. Tweaking stiffness and damping values of the suspensions decreases that moving resistance but also changes the feel of the suspensions. How did you solved this?
My vehicle doesn't slip at all (though I'd like it to do so). It instantly brakes and stops when I stop throttling even if no force is applied anymore, and only turns as long as I press the steering inputs. What did I miss?
Hi, First off, this looks very cool and fun to play with. I've tried implementing this in Blueprint. I have a problem when it comes to damping though. I can't make it work. I can use normal physics damping stuff on the block itself, but I can't figure out how to implement the damping described in the reddit. Is there any chance you could elaborate on the solution from reddit? I'm talking about this text: Get the current velocity at the suspension contact point (Cv) Project it onto the vehicle up vector to find the current suspension force (Cf) Calculate the new suspension force (Nf = UpVector x CompressionRatio x SuspensionStiffness) Calculate the delta suspension force (Df = Nf - Cf) Add the delta suspension force to the suspension contact point Could you elaborate a bit on what you mean by each of your variables? What I understand is. Cv is the velocity of the suspension point. So the total velocity of that corner of the vehicle. (This doesn't seem right to me as that would include the speed of the car as well. Or do you mean the speed of the corner of the vehicle relative to the center of the vehicle?) So what is this? I know how to project the vector onto the up vector of the car, so I have that down I believe. UpVector, I'm guessing this is your "upward force" that you mention in the video. Compression Ratio is clear. Stiffness would be a thing not discussed in the video. So I guess we need to experiment with this. I hope you won't mind explaining a little bit in extra detail, it would be much appreciated. Thank you.
I think what you want is not adding the Delta Force every tick, just add it less often and it should dampen it, btw, this reminded of that old game, Delta Force.
Vector3.ProjectOnPlane for Unity and Project Vector on to Plane node in UE -- Provide the function your vehicle's forward direction and the ground normal as returned by your raycasts.
Thank you, Mathew Wadstein recommends me to come here to solve the problem of a flying car that I would want to make. I would like to ask a question: how to solve the LineTrace can not let the asymmetric 3D car model correct hover off the ground? Once I changed the model, it will away roll over.
video is great, the idea is simple yet very effective. and yet I fail big time trying to implement it in Unity. Every time I try to code 4-point balance system it just starting to oscellate up and down, resulting in jiggly mess of a car. There is probably some tricks to make forces stick around certain point, but I am yet to figure it out.
Awesome. I'll probably keep banging my head against the wall with the built in UE4 vehicle stuff. But I'm not exactly thrilled with what I've gotten so far. I like your approach alot more. I have alot of weird issues with the PHAT stuff currently. Maybe I'll try and get something like what you have here, up and running. Although I may not be smart enough, hehe.
+mLichy911 I managed to get forward/backward movement and the vehicle "suspension". But it's very bouncy. I think in part of how i'm doing my impulses. It never actually settles/sits still at the moment. But, still very cool. I'll keep messing with it. Thanks!
i dont know if anyone will see this, but can anyone please help with my car being super slippery it feels like im accelerating/turning super slow like im on ice, similiar to if i set ground friction to 0 on a player controller character movement component.
So I eventually managed to figure out the springs, but I can't for the life of me figure out how you do the angular drag force. Tried all sorts of combinations of rotators and vectors but can't seem to find the magic equation. Don't suppose you'd be able to show the way you did it?
TheJamsh I've added some more information about damping the suspension here: www.reddit.com/r/unrealengine/comments/2dbhct/space_dust_racing_unreal_engine_4_arcade_vehicle/cjy18r8
SpaceDustStudios Awesome! The trickiest part seems to be just slowing the vehicle down over time now, adding a drag of some kind to it's movement. I'd like to not use UE4's "Linear Damping" though because it has annoying effects on things like Gravity and acceleration. Any idea how I would apply a force to slowly stop the vehicle?
TheJamsh Sorry for the late reply! If you're talking about slowing down overall velocity of the vehicle (in any direction), I'd use the linear and angular damping values - yes they will affect the terminal velocity of the object, but that's just like air resistance in real life. If you're talking about extreme slowing down (eg. violent braking), I'd probably put some custom code in there to scale down the object's world velocity, perhaps only on the horizontal plane if you wanted to ignore gravity completely.
(1 - (raycast hit distance / length of suspension)) This assumes your maximum raycast distance is equal to the suspension length, and the division bit should always be between 0 and 1.
Hey SpaceDustStudios! Really great stuff, thanks a lot! We are currently working on a game that also requires custom vehicle physics, like you implemented, and I am trying for weeks now to get proper physics done, and the movement itself is cool, but the car is always jerking when not moving on a perfectly smooth plane. I think our approach was too "realistic", with a physics asset for the vehicle and collision boxes for each wheel and the chassis. So, you only use one collision box and simulate the wheels just optically? I really like the idea of the suspensions, my problem is that I don't know what values are appropriate for suspension and mass for a simulated object, but I guess I will come up with some by just testing. I think the suspension really could do the trick for the "laggy" movement on the ground. As I said, we are pretty happy with the movement itself, except for driving on non-planar underground. Ah one more question: So, you guys use physics forces to accelerate and decelerate / turn the car? Currently I am using just WorldOffsets, and I am facing some collision problems in the terms of crashes (distinguish between small impacts and bigger ones, that would slow down the car, for when the car can drive again). So I was thinking wheter to switch to use physics forces for this. How is your performance with this? I think we would need about 22 vehicles in a match. Okay, I bother more about movement-prediction. Do you have already tested multiplayer and movement prediction? I will subscribe to this channel, awesome project, and we would love to stay in contact and maybe exchange some knowledge and experience :) Thanks in advance and greetings :) Mykon
Thanks for watching. Project is an operation that can be performed on two Vectors. There's nearly always a Project function in a Vector library, eg: docs.unity3d.com/ScriptReference/Vector3.Project.html docs.unrealengine.com/latest/INT/BlueprintAPI/Math/Vector/ProjectVectorontoVector/index.html
Dota 2 Extra It's the same principles regardless of your game/physics engine, they all use the same concepts and laws of physics. I prototyped these mechanics in Unity several years ago, then we moved them over to Unreal Engine. So I've seen it working in both engines with my own eyes. :)
iTooDear I’m pretty sure there’s a setting you can change that makes physics calculations frame rate independent. Can’t remember what it is off the top of my head though.
If someone managed to get something really similar in UE4 blueprints, please share it! Even with this video, I attempted, but faced too many complications. I can't figure out how to dampen the suspension without dampening every direction, including gravity. Also I can't figure out how to properly assign the suspension to a skeletal mesh.
Yeah, I already know most of the stuff here, but I wouldn't be able to explain it as cleanly and as easily consumable as you did. I have a question though: how did you handle networking with physics?
I really liked the explanations and the presentation of this video, however, sadly, it seems to be missing some key parts of the information, some of the variables and graph calculations just mentioned without detail. Not to mention that some of the sudo code presented was just copied and pasted without any great care of the comments used. Very frustrating and dissappointing. I genuinely have mixed feelings about this video: Great explanations and superb presentation but overall felt like a waste of time.
Thanks for the help Mr. Smartypants. When I set the local sideways velocity it disables gravity. Are you going to make a tutorial video on how to fix that?
Disappointed... trying to find a good resource for car suspension as a newcomer to unreal, and not impressed with how the solution you put here wouldn't actually work in an actual game, missing important info on dampers that newcomers like me would need to know - and in fact you did something completely different for your demo anyway and didn't bother to mention it here. wasted my time
Minty The unreal documentation is perfectly fine for what you need. This is for when you realise the unreal technicalities stop you making exactly what you want. This is the raw foundation behind what you actually want.... which is everything on a plate.
Minty well considering that dampers would be simply lerping a subtraction from a value and clamping potential values, I would say that doesn't need much work especially in blueprints.
See, what you just said is actually incredibly vague for a team or a person that's just trying this for the first time. In the situation I was in, what you've just written would not be of any help to me, and that's the whole point. You're acting like this is just comment knowledge and I'm dumb for not knowing. And the video does the same thing, which is why I took issue with it; it handwaves the whole suspension setup by saying 'now you make the suspension.' Like I said, what they proposed here is not what they use in the game; they admitted this themselves on a reddit thread, and it's obvious anyway if you try to implement it exactly as the describe and see that it doesn't work at all. I've since learned how it works from other sources.
+Minty I get what you mean, but nowhere does it state that this video is a tutorial. It says it's a "Physics Tour". In other words, they show you how they solved it. Kind of like how in movies you sometimes see a before and after on a scene they shot, to show you the CGI and effects. They don't tell you how they did it, they just give you a little peak to give you the idea of how they solved the problem they faced. It's actually quite surprising how much detail they went into in this video. Yes, not everything is clear as cake, especially not for someone who's new to it, but at least it shows you what you need to find out, and that's half the battle. Now you need to figure out the how. I've been working on trying to simulate suspension for 3 years almost, I was on the project for a few weeks, then stopped for months because I was so frustrated with it. These guys sent me in the right direction and lots of research later I finally have realistic damped suspension for the car I built inside of Unity3D. If you need some help with the calculations themselves, I can try explain them.
I really wish there were more videos like this. This couldn't have been explained any better.
TO EVERYONE WITH BOUNCY SUSPENSION: use the spring formula with dampening equation: F = -kx - bv where k is the "tightness" of the spring, x is how much the spring is compressed, b is the coefficient of damping, and v is the velocity of the point at which you are applying the suspension force.
For clarification, damping is a spring resisting change, which helps stabilize suspension.
Here is a snippet of my code:
float distance = SuspensionDistance - hit.distance; //This gets the distance the "string was pushed" in the context of this implementation
//hit.distance is the raycast's distance to the hit point
float force = -SuspensionStrength * distance + (SuspensionDamping * carBody.GetPointVelocity(corner).y); //the -bv had to be inverted for damping to work.
//SuspensionStrength is a constant that represents "k", and SuspensionDamping is a constant that represents "b".
I love you. lol
what about slip? i cant search simple formula
many mistakes here, it s not distance that u should calculate, but compression, so compression = 1-(hitDistance/suspensionDistance) - And global spring formula to get the force should be (compression * suspensionStrengh) - (SuspensionDampling*Zvelocity) (yeah UE is Zup) - Add to that that considering the local space physX calculations, suspensionStrengh is around 100 000 constant value, dampling around 100 to get a clean stable system
Thanks bro. It's 1am right now but thanks to you, I now have a (mostly) working suspension in Unreal haha.
is this c# if so can you send a link to the full code?
Thank you so much, I loved this video. Short, crisp, beautifully explained and the best part, completely engine independent. But I think you should add tags like Vehicle, Physics, Mechanics, and also common engine names like Unreal and Unity. This is what I've been looking for but it never showed up in search results...finally had someone in the Godot Forum recommending this to me.
This is so helpful that I will only need about 5 years of studying forces and vector math to get this to work the way you have. :D I got the box bouncing up and down and then hovering nicely with some dampening. However there are so many things that you didn't even mention that it will blow any beginner's mind and 500 hours away. Have a good day :)
This exactly what I"m looking for but don't have 500 hours :(
This is very impressive and insightful. I really appreciate videos like this that don't just "show" but also explain how your achieving your results. Very cool stuff. Hope to see more of these in the future!
That was a very good instructional video. Good build order of concepts, each explained with precision, and without getting too wordy. I hope you are going to continue making these because you're very good at them!
I like to thank you a million times.
Such a helpful video on the high concepts. I wish we had more videos like this. I just need to find a Unity tutorial on raycast suspensions.
Thank you! This is the best video i've seen for arcade handling, most others seem to focus more on simulator type handling.
This is awesome, thanks so much for making this video! It's very inspiring to see how you guys made your game and then also teach the principles in a very detailed manner, starting from the ground up. This is great video I know I'll keep coming back to when I'm working on vehicles!
Solid video! I am attempting to make a game with a huge amount of small cars (think, like, 100's of swarming micromachines) and your vid greatly helped me implement the car "drifting" physics I was looking for! I avoided the suspension, and simply made the base of each car a friction-less box (collider). But the rest? SO helpful!
Kudos!
greatly appreciate this. Thank you
I know this video is quite old, but the information is incredible valuable. Are there any additional resource available that would dig deeper in to the blueprints so that I may learn? This is incredibly close to what I am trying to achieve and I am still learning - and I have a LOT to learn.
Did you ever create a more in-depth look at the system(s) you created?
Wonderful video - and thank you very much.
Hi, thank you for the very informative video. Something that most game companies do not do.
I am experience the problem where the car takes off depending on where it's looking, For example, I jump off a ramp, I nose dive since it's launching off/on to the ground.
+moynul hussain You could probably disable the acceleration when the car is in mid air (if all rays are not hitting the ground). You could also divide the car's acceleration with the local pitch rotation of the vehicle, so when the car climbs hills, the steeper the hill, the less acceleration. I haven't tested this, so I'm not 100% sure if this would work. Also, it's a good idea to clamp the car's acceleration values to limit the max acceleration, so when you go downhill it doesn't multiply the acceleration so much.
+VideoGuy hey thanks for the reply, I'll show you a video demo of the implementation from your reply soon
a most entertaining video, and of course, such a fun looking game ! thanks
This is a very useful vid. Thanks for doing it.
Would love to see a tutorial for building vehicles this way, including wheel animation.
Not fully satisfied with Unreal's default vehicle options.
Fantastic breakdown.
HOW TO MAKE CAR LESS BOUNCY IN UNITY: set Drag and Angular Drag for car rigidbody. I used value of 1.
Fantastic and informative video!
So good! Thank you so much for sharing :) How does one calculate the surface angle from the raycast hit? (so that the car doesnt acclerate into the ground or air when the body isn't level with the ground)?
Could You give more details about Traction/Slip reduction in blueprint ? It'll be really helpful for me.
I know its old comment but for those who want an anwser for that
I did it like that
Take the dot product of velocity and right vector, then multiply it by right Vector, then multiply it by -1 and number you like (the higher number the higher friction) and plug it to add force on tick. (Only when on the ground)
@@Mrkarton thank you
@@gamergreat9505 You're welcome
@@Mrkarton thank you!!!!!
you're a life saver
Absolutely goat video
This video was super awesome and informative, and I built my arcade racing physics from it!
As an aside, for me, just having compression*thrust wasn't sufficient for the suspension, if you have issues with bouncing/oscillation a PID system can instead handle the force of each spring, P being a product of the error (goalDisplacement-displacement) D being the differential (Velocity of the spring compression) and I being the integral (Accumulating sum of the errors in each tick).
CHARACTERNAME what physics system did you use? I’m watching this and I see he said he didn’t use unreals physics system but haven’t they upgraded to nvidia physx? Would all of this workin inside of there
Thank you for this! amazing
I love this approach! I solved the suspension part but it generates a huge 'drag force when I want to move the wehicle forward...if I dont apply 'thrust force' to it, the wehicle slows down super fast. Tweaking stiffness and damping values of the suspensions decreases that moving resistance but also changes the feel of the suspensions. How did you solved this?
My vehicle doesn't slip at all (though I'd like it to do so). It instantly brakes and stops when I stop throttling even if no force is applied anymore, and only turns as long as I press the steering inputs. What did I miss?
Fantastic! Thanks Michael! :)
Great video!
Great stuff!
I did it but it just doesn't stay stable and wobbles. One suspension triggers one another.
great video
Hi,
First off, this looks very cool and fun to play with.
I've tried implementing this in Blueprint.
I have a problem when it comes to damping though. I can't make it work. I can use normal physics damping stuff on the block itself, but I can't figure out how to implement the damping described in the reddit.
Is there any chance you could elaborate on the solution from reddit?
I'm talking about this text:
Get the current velocity at the suspension contact point (Cv)
Project it onto the vehicle up vector to find the current suspension force (Cf)
Calculate the new suspension force (Nf = UpVector x CompressionRatio x SuspensionStiffness)
Calculate the delta suspension force (Df = Nf - Cf)
Add the delta suspension force to the suspension contact point
Could you elaborate a bit on what you mean by each of your variables?
What I understand is.
Cv is the velocity of the suspension point. So the total velocity of that corner of the vehicle. (This doesn't seem right to me as that would include the speed of the car as well. Or do you mean the speed of the corner of the vehicle relative to the center of the vehicle?) So what is this?
I know how to project the vector onto the up vector of the car, so I have that down I believe.
UpVector, I'm guessing this is your "upward force" that you mention in the video.
Compression Ratio is clear.
Stiffness would be a thing not discussed in the video. So I guess we need to experiment with this.
I hope you won't mind explaining a little bit in extra detail, it would be much appreciated.
Thank you.
I think what you want is not adding the Delta Force every tick, just add it less often and it should dampen it, btw, this reminded of that old game, Delta Force.
Voxels ftw!
I love that punching bag.
Im very confused at 3:35 as i cant find out how to get the forward vector projected on the road plane?
Vector3.ProjectOnPlane for Unity and Project Vector on to Plane node in UE -- Provide the function your vehicle's forward direction and the ground normal as returned by your raycasts.
Can anyone help me find the "local sideways component of the vehicles velocity"? I have no idea how to do that, and I've been stuck on it for weeks.
i believe that's the right vector of the velocity direction
Thank you, Mathew Wadstein recommends me to come here to solve the problem of a flying car that I would want to make. I would like to ask a question: how to solve the LineTrace can not let the asymmetric 3D car model correct hover off the ground? Once I changed the model, it will away roll over.
Wonderful
For the traction part, where is the opposite force applied?
How do you stop suspension bouncing up and down indefinitely ?
same here lol
Does anyone have an example of an implementation of this in godot?
How did you make the drift and the acceleration? Great Video
how would this be done in unity?
Hi Is this on the marketplace or is a working version of the code available to purchase for UE5.3?
I can't figure out how to do the drag?
great video!! but, how do you get the box to hover above the ground and not fall or fly up or bounce??
video is great, the idea is simple yet very effective.
and yet I fail big time trying to implement it in Unity. Every time I try to code 4-point balance system it just starting to oscellate up and down, resulting in jiggly mess of a car. There is probably some tricks to make forces stick around certain point, but I am yet to figure it out.
have you figured it out by now?
@@gamedevplayer yeah, there is similar implementation for unity now, I'm following it and it works fine
ua-cam.com/video/CdPYlj5uZeI/v-deo.html
Awesome. I'll probably keep banging my head against the wall with the built in UE4 vehicle stuff. But I'm not exactly thrilled with what I've gotten so far. I like your approach alot more. I have alot of weird issues with the PHAT stuff currently. Maybe I'll try and get something like what you have here, up and running. Although I may not be smart enough, hehe.
+mLichy911 I managed to get forward/backward movement and the vehicle "suspension". But it's very bouncy. I think in part of how i'm doing my impulses. It never actually settles/sits still at the moment. But, still very cool. I'll keep messing with it. Thanks!
Can this work on open world games? Also how are you doing the wheel rotation?
Thanks for the amazing tutorial. Just a quick question: to find the plane to project the forward vector on to, can I just average the impact normals?
i dont know if anyone will see this, but can anyone please help with my car being super slippery it feels like im accelerating/turning super slow like im on ice, similiar to if i set ground friction to 0 on a player controller character movement component.
Using ray casting is better than managing the wheels with ue4 classes ?
So I eventually managed to figure out the springs, but I can't for the life of me figure out how you do the angular drag force. Tried all sorts of combinations of rotators and vectors but can't seem to find the magic equation. Don't suppose you'd be able to show the way you did it?
Okay, nailed it... the magic is in the Dot Product :D
Still doesn't slow the damn thing down over time though..
TheJamsh I've added some more information about damping the suspension here: www.reddit.com/r/unrealengine/comments/2dbhct/space_dust_racing_unreal_engine_4_arcade_vehicle/cjy18r8
SpaceDustStudios Awesome! The trickiest part seems to be just slowing the vehicle down over time now, adding a drag of some kind to it's movement. I'd like to not use UE4's "Linear Damping" though because it has annoying effects on things like Gravity and acceleration. Any idea how I would apply a force to slowly stop the vehicle?
TheJamsh Sorry for the late reply! If you're talking about slowing down overall velocity of the vehicle (in any direction), I'd use the linear and angular damping values - yes they will affect the terminal velocity of the object, but that's just like air resistance in real life. If you're talking about extreme slowing down (eg. violent braking), I'd probably put some custom code in there to scale down the object's world velocity, perhaps only on the horizontal plane if you wanted to ignore gravity completely.
How did you get the Trace lines to stay on the corners of the box, when mine rotates it stays where the box was
How can I calculate compression ratio
(1 - (raycast hit distance / length of suspension)) This assumes your maximum raycast distance is equal to the suspension length, and the division bit should always be between 0 and 1.
Hey SpaceDustStudios! Really great stuff, thanks a lot! We are currently working on a game that also requires custom vehicle physics, like you implemented, and I am trying for weeks now to get proper physics done, and the movement itself is cool, but the car is always jerking when not moving on a perfectly smooth plane. I think our approach was too "realistic", with a physics asset for the vehicle and collision boxes for each wheel and the chassis. So, you only use one collision box and simulate the wheels just optically? I really like the idea of the suspensions, my problem is that I don't know what values are appropriate for suspension and mass for a simulated object, but I guess I will come up with some by just testing. I think the suspension really could do the trick for the "laggy" movement on the ground. As I said, we are pretty happy with the movement itself, except for driving on non-planar underground.
Ah one more question: So, you guys use physics forces to accelerate and decelerate / turn the car? Currently I am using just WorldOffsets, and I am facing some collision problems in the terms of crashes (distinguish between small impacts and bigger ones, that would slow down the car, for when the car can drive again). So I was thinking wheter to switch to use physics forces for this. How is your performance with this? I think we would need about 22 vehicles in a match. Okay, I bother more about movement-prediction. Do you have already tested multiplayer and movement prediction?
I will subscribe to this channel, awesome project, and we would love to stay in contact and maybe exchange some knowledge and experience :)
Thanks in advance and greetings :)
Mykon
+Sovereign Oh men thanks for this video, after implementing the suspension you explained, all the movement problems disappeared :)
1000 likes, I was the one who gave 1 thousandth like.
lol best punching bag ever XD Nice video thanks.
Has anyone implemented this in Godot yet? I'm considering making this and sharing it as an MIT addon.
Really great breakdown. I'm particularly curious about the traction/slip reduction. How do you project the velocity to the sideways vector in BP?
Maybe simply taking the dot product of the velocity vector and the "Get Right Vector"?
Thanks for watching. Project is an operation that can be performed on two Vectors. There's nearly always a Project function in a Vector library, eg:
docs.unity3d.com/ScriptReference/Vector3.Project.html
docs.unrealengine.com/latest/INT/BlueprintAPI/Math/Vector/ProjectVectorontoVector/index.html
u have any idea how this can work or make a copy for unity3d?
Dota 2 Extra It's the same principles regardless of your game/physics engine, they all use the same concepts and laws of physics. I prototyped these mechanics in Unity several years ago, then we moved them over to Unreal Engine. So I've seen it working in both engines with my own eyes. :)
u havent the source on unity¡?
I'm using unreal engine 4 and was wondering how you get those numbers to display in game like that.
+Keyeszx search for "draw debug"
this is great technique but how do u handle force on low fps? as i remember force depends on fps...
iTooDear I’m pretty sure there’s a setting you can change that makes physics calculations frame rate independent. Can’t remember what it is off the top of my head though.
If someone managed to get something really similar in UE4 blueprints, please share it! Even with this video, I attempted, but faced too many complications. I can't figure out how to dampen the suspension without dampening every direction, including gravity. Also I can't figure out how to properly assign the suspension to a skeletal mesh.
did you ever find any blueprints or finish making your own blueprints?
+Luminance Ghost No, sadly.
+VideoGuy darn
I got some pretty good results by setting the dampening to the compression ration of the suspensions.
It still dampens in all directions which isn't how a real car would behave. It wouldn't make sense on an arcade racer either.
NICE!!!!!!!!!!!!!!!!!!
duno how to make sideweys componet any tip?
think its just the velocity vector DOT the get right vector
кто то делал это для Unity?) напишите мне пожалуйста!
Yeah, I already know most of the stuff here, but I wouldn't be able to explain it as cleanly and as easily consumable as you did. I have a question though: how did you handle networking with physics?
i'm making a crash team racing fangame called crash team racing all stars
I really liked the explanations and the presentation of this video, however, sadly, it seems to be missing some key parts of the information, some of the variables and graph calculations just mentioned without detail. Not to mention that some of the sudo code presented was just copied and pasted without any great care of the comments used. Very frustrating and dissappointing. I genuinely have mixed feelings about this video: Great explanations and superb presentation but overall felt like a waste of time.
Thanks for the help Mr. Smartypants. When I set the local sideways velocity it disables gravity. Are you going to make a tutorial video on how to fix that?
Disappointed... trying to find a good resource for car suspension as a newcomer to unreal, and not impressed with how the solution you put here wouldn't actually work in an actual game, missing important info on dampers that newcomers like me would need to know - and in fact you did something completely different for your demo anyway and didn't bother to mention it here. wasted my time
Minty The unreal documentation is perfectly fine for what you need. This is for when you realise the unreal technicalities stop you making exactly what you want. This is the raw foundation behind what you actually want.... which is everything on a plate.
No, just dampers.
Minty well considering that dampers would be simply lerping a subtraction from a value and clamping potential values, I would say that doesn't need much work especially in blueprints.
See, what you just said is actually incredibly vague for a team or a person that's just trying this for the first time. In the situation I was in, what you've just written would not be of any help to me, and that's the whole point.
You're acting like this is just comment knowledge and I'm dumb for not knowing. And the video does the same thing, which is why I took issue with it; it handwaves the whole suspension setup by saying 'now you make the suspension.'
Like I said, what they proposed here is not what they use in the game; they admitted this themselves on a reddit thread, and it's obvious anyway if you try to implement it exactly as the describe and see that it doesn't work at all.
I've since learned how it works from other sources.
+Minty I get what you mean, but nowhere does it state that this video is a tutorial. It says it's a "Physics Tour". In other words, they show you how they solved it.
Kind of like how in movies you sometimes see a before and after on a scene they shot, to show you the CGI and effects. They don't tell you how they did it, they just give you a little peak to give you the idea of how they solved the problem they faced.
It's actually quite surprising how much detail they went into in this video. Yes, not everything is clear as cake, especially not for someone who's new to it, but at least it shows you what you need to find out, and that's half the battle. Now you need to figure out the how.
I've been working on trying to simulate suspension for 3 years almost, I was on the project for a few weeks, then stopped for months because I was so frustrated with it. These guys sent me in the right direction and lots of research later I finally have realistic damped suspension for the car I built inside of Unity3D.
If you need some help with the calculations themselves, I can try explain them.