|
Author |
Message |
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 13:20 - 28 Apr 2020 Post subject: Motorcycle Physics |
|
|
On a whim I thought I'd have a little play with Unity. All the scripting is C# and it plays nicely with Visual Studio so I thought "well I'm half way there, how hard can it be?"
A good chunk of physics - gravity, drag, etc. - is built in. So I thought I'd have a go at simulating a motorcycle
I'm starting to glaze over a little reading this:
https://en.wikipedia.org/wiki/Bicycle_and_motorcycle_dynamics
I'm thinking there could be two approaches:
1) Treat the vehicle as a single body and simulate things like suspension, wheelies & stoppies.
2) Create representations of the components - wheels, suspension, frame, etc. - which individually have relatively simple physics, bolt them all together and see what the physics engine does with it all. ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
stinkwheel |
This post is not being displayed .
|
stinkwheel Bovine Proctologist
Joined: 12 Jul 2004 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
Lord Percy |
This post is not being displayed .
|
Lord Percy World Chat Champion
Joined: 03 Aug 2012 Karma :
|
Posted: 14:23 - 28 Apr 2020 Post subject: |
|
|
It would definitely be quicker to simulate all the bits on a single motorcycle shaped block, and is possible to do it with a sense of realism too.
A motorcycle has the following main forces acting on it:
1. Driving force (happening at the point where the wheel and ground are in contact)
2. Weight
3. Normal/"Reaction" force
3. Friction (happening in the opposite direction to force 1)
4. Wind Resistance (happening in the opposite direction to force 1)
You simply ("simply") need to calculate the resultant direction of motion based on each of those things (and lots of other things if you want to add realism, but best to start with as spherical a cow as possible ).
The motorbike can be a solid block, for all it cares. Everything happens in the maths. |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 14:24 - 28 Apr 2020 Post subject: |
|
|
Maybe. A wheel is quite straightforward in itself (with regards to physical forces) but then you have the contact patch, the wheel bearing, the interaction with the forks... and that's just the front wheel!
Hmmm....
Rather than "run before you can walk" I'll start with something a bit simpler: a unicycle simulation. Left controller stick can shift your balance (centre of gravity) and right for movement. The whole "upside down pendulum" thing. ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
weasley |
This post is not being displayed .
|
weasley World Chat Champion
Joined: 16 Oct 2010 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
- |
This post is not being displayed because it has a low rating (Confusing). Unhide this post / all posts.
|
- Super Spammer
Joined: 22 Oct 2013 Karma :
|
Posted: 14:41 - 28 Apr 2020 Post subject: |
|
|
Lord Percy wrote: | It would definitely be quicker to simulate all the bits on a single motorcycle shaped block, and is possible to do it with a sense of realism too.
A motorcycle has the following main forces acting on it:
1. Driving force (happening at the point where the wheel and ground are in contact)
2. Weight
3. Normal/"Reaction" force
3. Friction (happening in the opposite direction to force 1)
4. Wind Resistance (happening in the opposite direction to force 1)
You simply ("simply") need to calculate the resultant direction of motion based on each of those things (and lots of other things if you want to add realism, but best to start with as spherical a cow as possible ).
The motorbike can be a solid block, for all it cares. Everything happens in the maths. |
By "Weight" you mean gravity, (weight is not a force),
What about the gyroscopic force keeping it upright? ____________________ TZR250 2MA road, TZR250 1KT road, TZR250 2MA race, TDR250, YZF-750R Boost colours.
Jaguar S Type 3.0 V6 Sport R, VW Transporter T5 GP LWB Shuttle 140ps DSG. |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Lord Percy |
This post is not being displayed .
|
Lord Percy World Chat Champion
Joined: 03 Aug 2012 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
Lord Percy |
This post is not being displayed .
|
Lord Percy World Chat Champion
Joined: 03 Aug 2012 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
- |
This post is not being displayed because it has a low rating (Off Topic). Unhide this post / all posts.
|
- Super Spammer
Joined: 22 Oct 2013 Karma :
|
Posted: 15:09 - 28 Apr 2020 Post subject: |
|
|
Lord Percy wrote: | - wrote: |
By "Weight" you mean gravity, (weight is not a force),
What about the gyroscopic force keeping it upright? |
No, weight is a force. Gravity is the acceleration caused by a gravitational field, and the resultant force felt by objects in the field is called weight.
F = ma
W = mg
Gyroscopic forces are the "lots of other things" I mentioned which aren't strictly necessary in the first instance. To start with you can just program something that simply goes forward and turns depending on the lean you give it. |
Oh fuck me, here we go again...
Quote: | The weight of an object is the force of gravity on the object |
____________________ TZR250 2MA road, TZR250 1KT road, TZR250 2MA race, TDR250, YZF-750R Boost colours.
Jaguar S Type 3.0 V6 Sport R, VW Transporter T5 GP LWB Shuttle 140ps DSG. |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Lord Percy |
This post is not being displayed .
|
Lord Percy World Chat Champion
Joined: 03 Aug 2012 Karma :
|
Posted: 15:09 - 28 Apr 2020 Post subject: |
|
|
mpd gave me a downvote for correcting him
Don't even bother you thick cunt, you've ruined enough threads and you are absolutely categorically wrong here. Don't even try |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 15:21 - 28 Apr 2020 Post subject: |
|
|
I started with a squashed sphere (bit like a wheel) added a stick and another sphere on top (vague unicycle shape) and swapped the X/Y directional translation for a propulsion/rotation sort of thing and the thing "drives" around and eventually topples over! Now I'm going to try add add a "balancing force" from the other controller stick... fascinating stuff ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
bhinso |
This post is not being displayed .
|
bhinso World Chat Champion
Joined: 21 Jun 2008 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
kolu |
This post is not being displayed .
|
kolu Nova Slayer
Joined: 29 Sep 2019 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
stinkwheel |
This post is not being displayed .
|
stinkwheel Bovine Proctologist
Joined: 12 Jul 2004 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
weasley |
This post is not being displayed .
|
weasley World Chat Champion
Joined: 16 Oct 2010 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 17:25 - 28 Apr 2020 Post subject: |
|
|
Oooh! Wheel colliders They have suspension (with damping) forward and sideways friction.
I stuck two under a box and if you turn the wheel left the "bike" tips right. Countersteering! ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
bhinso |
This post is not being displayed .
|
bhinso World Chat Champion
Joined: 21 Jun 2008 Karma :
|
Posted: 15:28 - 29 Apr 2020 Post subject: |
|
|
I've been Donked
Which part of what I wrote do you disagree with? It's Newton's second law of motion, F=ma |
|
Back to top |
|
You must be logged in to rate posts |
|
|
xX-Alex-Xx |
This post is not being displayed .
|
xX-Alex-Xx World Chat Champion
Joined: 12 Sep 2019 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 15:50 - 29 Apr 2020 Post subject: |
|
|
Had a good play with the physics. You can apply forces, rotational torque, change centre of mass, all sorts! TBH I think I've gone completely through the looking glass when terms like "Quaternion" and "Euler Angles" are casual parlance on the Unity forums - I can just about handle Vectors
Found a nice GitHub example:
https://github.com/Kright/MotorcyclePhysics
It's not a true representation but the bike does lean as it turns. You can turn too sharp and lowside it. You can come to a stop and it wobbles and falls over. Quite satisfying how the bike dives when you brake.
Long term I'm thinking of one of those apocalyptic "endless road" type games but with bikes. ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 13:34 - 30 Apr 2020 Post subject: |
|
|
Here's a bike that zooms about:
https://send.firefox.com/download/fee24170e02b5baa/#vVoqTV-16FWK7rKhWct05A
You'll need an XBox style controller.
Left Trigger: linked braking - 80% front, 30% back, proportional
Left Button: instant 90% front brake
Right Button: instant 50% back brake
Right Trigger: throttle, proportional
Left Stick: steering
Keyboard Backspace: reset bike (sometimes)
Keyboard C: camera change
What I'm happy with: front forks dive in quite a satisfying way
What I'm not happy with: swing arm is fake. The rear wheel is actually attached to the main frame (via invisible shocks) in the same way the front wheel is. It therefore moves up and down in a straight line rather than rotating around the swing arm bearing
Still working on it: the bike turns and leans and lowsides quite well <30mph. Over 30mph it starts to get tank-slap and go a bit mad. There's still lots of things to tweak though, almost anything you could think of that's in real world is here; barely scratched the surface! ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 00:40 - 01 May 2020 Post subject: |
|
|
Fixed the swing arm. I did try and make a "real" swing arm but it was starting to get fiendishly complicated with hinges and springs. Instead I did the decent thing and cheated. I adjusted the angle of the rear (virtual) shock so the angular effect is barely noticeable. The swing arm just rotates to "look" at the rear hub. So that mean's the bike's going to be a twin-shock
Might upload a new version tomorrow, depends if it's sunny out ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Lord Percy |
This post is not being displayed .
|
Lord Percy World Chat Champion
Joined: 03 Aug 2012 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 12:26 - 01 May 2020 Post subject: |
|
|
Basically: user input + maths goes into the wheel colliders. The collider reactions go into more maths to feed back into the model (e.g. rotate the front wheel in two axis but the wheel hub in only one...)
So I have to provide the maths "glue" and the models. Unity provides the physics: "Oh, you want to apply 100Nm of torque to this motor? Let's see how that turns out..." and it weighs up drag, friction, gravity, interaction of materials, etc.
The Wheel Colliders are a "black box" convenience item which a purist would replace with hinges and springs for something like single wishbone suspension (i.e. a swing arm.) ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 16:11 - 02 May 2020 Post subject: |
|
|
Version 2:
https://send.firefox.com/download/011bf7bd923f6a05/#JlQprkNiI1jNRf6XTMOiWQ
Quick video if you don't have a gamepad:
https://img.youtube.com/vi/QzdsUaaO_us/0.jpg
Changes:
Swing arm + rear suspension working. Admittedly the suspension is a bit exaggerated but it looks kewl
Pick Up Bike is now Fire1 (XBox A)
Cam Switch is Fire2 (XBox B)
Mouse moves the camera in View 1
Right stick throws some simple torque in the mix to get a bit of lean on (or shift your weight over the front wheel)
Travelling at walking pace drops the centre of mass below the ground to simulate "foot down" but this is a cheap trick / shortcut just for now
Added a jump. Air stability is zero so you'll be lucky to land it even with some appropriate lean - you have been warned ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 20:31 - 03 May 2020 Post subject: |
|
|
The handling might be a bit shit but I'm happy with the mechanics: swing arm, suspension, steering.
Knocked this up this afternoon in Blender:
https://i.imgur.com/iIpdSOy.png?1 ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Old Thread Alert!
The last post was made 3 years, 360 days ago. Instead of replying here, would creating a new thread be more useful? |
|
|
|