Unity hoverboard in 10 steps (short tutorial)
Вставка
- Опубліковано 2 кві 2020
- I tried to explain how to make a hoverboard in Unity in 10 steps. For the physics material 'friction combine' setting, instead of 'minimum' you need to use multiply to make it frictionless.
- Ігри
What the heck this is actually a really elegant solution.
Your videos are the best. They’re short, simple, and in the end you understand everything cause all the code is yours. Keep it up man!
I always have trouble with that last step
lol
Pshh nah it's like sooo easy
First you gotta... uhh... Y'know... Ummm
dont think, just do
Codeer be the one to save me with all these innovative elegant solutions thank you for sharing
Surely the kind of tutorial needed as well as deserved!!!
Keep up the good work!
We need more man. I remember seeing this on Twitter. Keep it up 👍
How the absolute heck do you not have more subs??? I’m definitely going to attempt this (probably as a vehicle instead of a hover board)
Great video! I love this style of tutorials!
man this is some top tier content, keep it up!!!
Adding an inclination to the hooverboard when one side is higher in relation to the ground could be a good idea. That little drift which happens casually in movies when spaceships turn when being chased. Although, nice work, your game it's getting really interesting.
I would also suggest finding the lateral component of velocity (side to side) and adding a force to counteract this a bit, so you don't slide sideways as much. This also allows you to reduce the drag quite a bit while still retaining control when turning. And adding a slight roll torque to the board when turning adds some realism.
This is so cool man. Good work!
Last step: add a game to your hoverboard.
this is amazing
Awesome, thanks!!!
thanks , this is awsome :))
Nice, thanks.
Nice very simple and nice
great thing about this is that it can be used for multiple things, I'll see if it works for a boat
Hi, I love your work! How did you attach th player to the hover board? I can't have a good look with a transform.parent ...
I wonder if it's mostly the same and possibly even having lesser steps if it's just a literal board that stays on the ground but can still move the same
These lines you use, do you draw them by script or is it a feature of the unity debug?
Hi man, i've followed your tuto, but my board side flip when is floating over a sphere.
I've not understand well how to add force at position, how do you calculate the force to apply it ?
to add force at position just use rigidbody.AddForceAtPosition();
@@blaccy5991 what do we put in the parameters
@@jmas2593
You could up the mass, drag and angular drag buuttt.....
you could also follow these steps:
1. Make a hoverboard script
2. Make a vector3 array
Vector3[] Points;
3. Make a function called Balance where you raycast down from your points and apply forces at the points
Example:
for (int i = 0; i < points.length; i++)
float amount = // distance between points[i] and raycastHit
rb.addForceAtPosition(points[i], vector3.up * mathf.abs(amount));
4. Add damping based on height of point - desired height using the code I wrote before.
5. Up the mass, drag and angular drag 😁
I am noob in noob in unity so can you just paste the whole script here😭
For the force, use a raycast that travels the distance you want the board to hover above the ground (desiredHeight). Then use Mathf.Pow((desiredHeight - hit.distance), 2) * someConstant. The power factor just gives the force an inverse square feel which is more realistic for a force field, and the constant is a scaling factor you can tweak until the hover seems right. I would also use ForceMode.Acceleration for adding forces, so it isn't dependant on the rigidbody mass.
It also helps to add a transform below the hoverboard and set this as the boards center of mass (rigidbody property). This will lower it's center of gravity.
just a lil question : how do we raycast just tell me how or the code so i could understand cuz I use visual scripting (in 2021 version)
how do you change the height at which it hovers?
Someday I will create a wipeout like game
Or you could just cheese it and animate the collider and position through code
What if the raycast points are in the front, back, left and right. In the edges instead of corners?
Also what if you put 9 raycast points? Let's say the 4 raycast points in the corners are shorter and the other 5 raycast points (front, back, left, right and center) are longer.
The more raycast points you have the more accurately you will be sampling the height of the terrain, so in theory it can only make the movement of the hoverboard look more realistic. However if performance is an issue a small number like 4 should probably be enough. Another consideration is how much is the terrain actually varying? If the terrain is mostly smooth and only changed height gradually you won’t get that much of an advantage by sampling the terrain lots and lots of times compared to only a few times.
@@raphaelguionaud7839 Thanks for telling me about this. I was thinking about the hover physics for anti-gravity racing ships like Wipeout Omega Collection. I also wanted it to work on really rough terrains, racetrack borders and racetrack edges that don't have borders. This is when I thought putting four raycast points on the corners might not be good for the hover physics I want. Game physics can affect the gameplay a lot, so I have to be considerate about it.
Just thinking about these things in game development really interests and amazes me a lot.
can you tell me your pc specs??
"10. Add a game" 💀
Can you show the code in the videos it will really help for noobs like me
I am actually doing it. Once is finish i will give to u
@@pokerroler Are you done ?
@@George-pk5jw sorry guys complete forgot give 1 more day that im having trouble with other things
@@pokerroler No problem, waiting
@@George-pk5jw im actually having a problem with an if but is almost done
The 10 step is the easiest one
If it's ok can you make an in depth tutorial
I think the point of this is that it's simplistic, yet easy to understand. If you can't do one step by yourself, there are many great resources to learn those steps from.
@@kintrix007 Im no big brain coder so thats why, im not familiar with unity.
@@kwaku8316 What I was trying to say is, if for example you don't know how to use raycasts you can search "Unity Raycast" or "How to use Unity raycasts" etc... The steps he described already have an oversaturated amount of tutorials.
@@kintrix007 Thats the things I didn't know it was called ray cast
@@kwaku8316 "3. Raycast down from the points to find distance to the ground"
Of course, it's not that hard to actually miss it, so that's understandable.
Good luck, though!
0:15 How to make those lines and points appear?
okay now I know while ago, it's the Gizmos methods called in OnDrawGizmos()
Gizmos.DrawRay() and Gizmos.DrawSphere()
damn
Hi can anyone teach me the turning part, i am unable to handle the torque, pls.
Hi how does your code look like? or have you solved issue already?
rigidbody.AddTorque(hoverboard.up, torqueAmount, ForceMode.Acceleration);
You wouldn't get this from any other guy
How to add points. Please make a tutorial on that. I really need that
they're just gizmos if u want just put empty without the gizmos
This can easily be used as an enemy drone
Why would u make it that complicated?
@@AhmedMohamed-zj1qc wait is there simpler way, this is how i implemented it in my projecy
@@maindepth8830 i mean yes there is a simpler way but like i assure you that this way is better but anyway i dont really care abt polishing my projects so keep doing it the way ur doing it😁
@@AhmedMohamed-zj1qc ah thank you
How can I make the hoverboard follow this points?
Do you mean how to use the points to make it hover? You can use AddForceAtPosition for every point to keep it floating in the air.
@@Codeer I made this, but only the points is floating, Sorry I'm new on unity
@@josimar8497 make sure to parent the points to your hoverboard and apply the forces upwards to a rigidbody attached to the hoverboard itself.
@@Codeer Ok thank you very much
@@Codeer Works nice! Thanks
@codeer, How do you add "point"
its just gizmos, u can just use an empty if u want the point use this in the script:
private void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawSphere(transform.position, 1);
Gizmos.DrawSphere(hit.point, 1);
}
Step 10 unclear