Ya'll kept asking so Part 2 is now up.. (Adding Collision) Check it out : 📺 ruclips.net/video/CpXT5So1Gbg/видео.html Also find an updated copy of the script used in this video over there in the description..
Thank you. I try to throw in explanations and tips here and there.. :) It's a balancing act for sure. I could make hour long videos if I broke down everything but I do my best to figure out what are the important bits :)
This is an extremely clean tutorial. The descriptions of everything is incredibly concise and I must say the system design is very good. I do think there might be better ways to handle certain things but nothing can be perfect or match every requirement for each person's project. Excellent job.
@@SpawnCampGames no problem but do you use discord I need some help from a professional in unity just small things which I need in my car game I am making
@@sumanojha5310 I do use Discord, although my channel is currently private and invite only.. I can recommend joining the Official Unity Discord. It's a great place to ask for help and I am active there, as well :)
Well, Thank you fam! I personally don't like the way I sound but I think that's the case with us all. xD.. I try to joke and keep the material fun because that's the way it should be.. Gotta be enjoying what you do!! :) But anyways, thanks for the shoutout and thanks for watching..
Really appreciate the visual explanations. I taught the only way to create car controllers in unity was by using wheel colliders. Thanks for the insight!
Thanks man, this is what I have been looking for about 1 month. You are genius bro. Thanks again for such a detailed and well explained tutorial. You deserve much more.
This is literally AMAZING the only thing that makes it not so viable is the way the car follows normals of the road via using raycast. if it went straight up a 45 degree angle it snaps to the normals resulting in an akward transition.
Many thanks for this, it is awesome! One little thing I would say is that if you are not accelerating (either forward or backwards) then you can't turn the car, but is the only thing I saw missing. Awesome job!!
Cool tutorial, really nice work...but i have problem colliding with walls, the car goes inside or the wall until he reach the sphere colider any ideas for that?
Really nice system but my only concern is how quickly the car accelerates and deaccelerates. How can you get it to ramp up to top speed slower and and come to a stop longer when not on the throttle?
Loved the tutorial. I used it to build a quick car controller but I had an issue that when I stopped pressing forward/backwards I lost my turning. So I swapped in a DOT product and stopped using the moveInput for the steering. Here are my changes :) float turnStepVelocity = Vector3.Dot(transform.forward, (SphereRB.position + SphereRB.velocity - SphereRB.position).normalized); float turnStep = turnInput * turnSpeed * Time.deltaTime * turnStepVelocity; transform.Rotate(0, turnStep, 0, Space.World); // float turnStep = turnInput * turnSpeed * Time.deltaTime * moveInput; // transform.Rotate(0, turnStep, 0, Space.World);
Tks so much for this tutorial, I had some issue due the Visual Studio update but in the end I could finish this tutorial. I was thinking how to disable the rotation when the car is on the ground.
bro i really dont understand what do you did to make the car stop bouncig on the start of the video im using another car model and it keeps bouncing plz explaing in another video how u doit
actually i figured out, i put the "transform.position = sphereRB.transform.position;" on the fixed update since the pivot points of the sphere and the car was in the same exact place and they dont stop bouncing
Hi SpawnCampGames really good tutorial! Can you please tell me how you can get the car skidding a bit more when acceleration is released, it seems to stop turning too quick.
Hey, I have a request, if you could do a part 2 about collisions(Solving the issue with parts of the car entering objects). Whilst it might seem simple, Ive tried many things and its just not working!
Do you have the sample code/script somewhere... I'm trying to figure something??? you move the sphere forward/backward? do you turn the sphere? I just see you turning the car parent empty gameobject??? So how does the sphere change the direction it goes in for the rest to follow???
Is it possible to set up a more accurate collider for the mesh of the car, to crash with other cars or walls, I can't figure out how to make the collisions from the car affect the sphere.
this is an arcade controller really meant to be viewed top down and have bumping type collisions.. really accurate collisions aren't really something i know how to achieve with this controller.. altho I have been experimenting with collisions and I have a part 2 for this video coming out.. This uses a simple box collider and another rigidbody thats seperate from the car.. and sets its position to match the sphere and rotation to match the car.. Example: gfycat.com/orderlysatisfiediberianlynx
I adjusted the pivot for the sphere and the car so that its at the same point just like you did, the transform of the sphere is also 0,0,0 but still the car just bounces and falls below the platform.
If your using the same car asset: The Car will be @ 0, 0.5, 0 The Car graphics will be @ 0, -0.5, 0 The Sphere will be @ 0, 0, 0 If you pull the sphere outside of the Car gameobject their transforms should match.. When the car is assembled in the way of the video their transforms will not match..
@@anupamverma7677 bro I had the same problem, don't really know how but i somehow fixed it I think, believe you just have to be very precise with the pivot point
Hey @SpawnCampGames I am struggling with getting the pivots of the CarBody to line up with the MotorSphere. I tried to manually change the rotation of my kart mash through Blender so the rotation (X, Y, Z) was all set to 0. I also tried putting the kart in an empty model set in the same location as the MotorSphere. Note that I am using my own model. Not a marketplace model. What can I do to manually set the pivot point to where I want so the vehicle doesn't fling into oblivion?
Yea, its a thing you just need to fine tune until you get it right.. I could suggest just using primitive shapes like a normal ole unity cube and get that working and then change out the cube for ur artwork.. If it will help I have the project on Github github.com/SpawnCampGames/ArcadeCarController you can click the Green Code button in the top right corner and download the zip file.. Its a normal Unity project. so you can extract it to a new folder and open the project up in Unity.. could use it as an example to help ya out..
Surprised you don't have more followers very clear and alot of explanation and ur not typing at lightning speed so I'm actually able to follow along and not pause every 5 seconds xD Two questions though one why didn't you just unchild the motor sphere in the editor instead of script was it just to keep everything together/more clean And two how did you get those extra things in ur code like it says what the different variables are like the x y and z or the origin and direction in the ray cast there in gray letters I have the auto complete thing installed but I don't get stuff like that? Hope you have a great day
The reason I don't unparent the Motor sphere in the editor is because this way you can keep them together as a prefab, and drag it around to a good starting position. The things you see are called inline tips/hints. ruclips.net/video/XE5q8A5vz3k/видео.html I have a video explaining how to turn them on. They're great for beginners so you can understand your code better. But personally I use them often when I write out a function of something that takes in many arguments for example if i have: public void SetUpSkybox(Color colorOfSky, float intensityOfLight) when I go to type out the function it'll help me know what belongs there.. and also it allows me to quickly glance at functions and know whats being passed in w/o me having to track down the function..
Why, yes.. If you check out the video @ 13:16 You'll see the code before I modified it to only turn while moving forwards and backwards... The reason I did it that way is because it sorta turns into a TOP and just spins in place :D... If you are talking about turning the car with w/e momentum is left over from accelerating, there are ways to do it but I chose not to for this video because of the nature of the car controller.. ( This video has gotten a lot of attention so I most likely am going to do a Part 2 where we add onto it. And I'll remember your question when I do :) )
@@random_precision_software ok coool, I just started getting into URP for my new Space Adventure game I'm currently working on but I haven't done much with either... Would be a good chance for me to learn some things as well.. The next video probably won't be URP or HDRP since I have to get familiar with it myself first.. BUT a promise is a promise.. And I'm starting a brand new project as I type. :) Thanks for the SUB.. check in tomorrow or the next day (at the latest) for a new video :) :) :) happy developing
Omg wow thank you so much for this tutorial!! I was trying to make a simple racing game and I tried using wheel colliders but I kept having so many weird bugs, this was so easy and clear and this might have saved my project!!
The same Input.GetKeyDown would be what you use in any scenario. The rest of the code wouldn't matter docs.unity3d.com/ScriptReference/Input.html Note, Rigidbody movement should usually be done in the FixedUpdate(). If you put Input in there some of it may be missed because the FixedUpdate() runs at a much slower frame rate. Although, it doesn't seem to stop them in examples: docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html
I'm so close to getting this working. I'm stuck at about 15:30. My car moves much slower and all the setting are correct. The car is not going fast enough to go off the jump. And when it hits the jump the SphereMotor jumps out of the car and everything goes crazy. I can't figure out what's different!
I figured out the speed problem for all those doing this tutorial. The ARCADE Car Asset has been updated and some of the prefab cars have wheel colliders. They need to be deleted and the speed will be correct.
Hello, this is awesome and so simple. Thank you. I would like to ask for a little help tho regarding streering, how would i approach steering whie decelerating, so the input to forward is no longer active, but the car still carries the initial momentum and i would like to be able to steer in the time window before complete stop.
@@milanmolnar3820 true.. but I only glossed over it.. I'm actually workin on a part two with better steering collision and extras :) stay tuned if u wanna check it out!
spawncampgames.github.io/Drift/ here's a quick web build i threw up.. I'm still tweaking with the steering but I'm assuming this is similar to what you're asking for..
Thanks for the timestamp.. We need to multiply it by its own transform to apply it to our 'FromToRotation' quaternion rotation. Quaternions are magic.. and multiplying a quaternion isn't the same as actually multiplying it.. To be completely honest I've been doing Unity for quite a while now and still can't explain them.. forum.unity.com/threads/quaternion-rotation-along-normal.22727/ The 2nd post also explains why this is done.. Sorry I can't break it down in a good way :D
Very nice! Thanks for sharing! Is there an easy way to smoothly rotate the car as it enters a ramp and also when it lands? Rather than suddenly jerking the rotation, maybe lerping it to the same rotation as the ramp?
Anyone know why I need to crank the values up to get any speed, the values in this video still go slow? I'm wondering if theres a reason why this is occuring.
In Unity when you are dealing with Physics values, they tend to be very high.. in the thousands. If you are translating.. (moving the objects with its transforms) you can use smaller values.. because its like units per second.. a Unit is a big area in Unity.. (a meter)
hi! i have a problem with the script at 9:15 ; my car doesn't want to move , i don't find errors and i retype the script but it's the same, can you help me please ? thanks !
Hey, so I ran into a problem, so I have the camera follow the car but when it turns, the camera faces the front of the car and I always want it to be following the back of the car. Any help?
I use the Cinemachine package from Unity.. super simple to set up a good follow camera with that practically drag and drop.. or u could just track the cars transform and add an offset to put it behind the car.. but the way it drifts probably would be kinda disorienting..
Try debugging what the Raycast is hiting.. I'd also say make sure your Raycast is long enough to reach the ramp.. Another good way of troubleshooting is by using OnGizmoSelected method or similar and its DrawRay function to redraw your Raycast in the editor window to make sure its where you'd expect it to be. Theres a part two where we redo the car and also a link to a project file that you could compare to. Maybe one of the two would also be useful to help you figure out where the problem is.
for some reason my scene isn't behaving like ur scene, first difference when I added the sphere to the car it doesn't bounce at all it just falls straight down once I start the game. After I followed everything in the video private void FixedUpdate() { sphereRb.AddForce(transform.forward * moveInput, ForceMode.Acceleration); } this script doesn't allow my car to move even though I properly referenced it and set force to 200 in inspector. I'm at time 9:00 and nothing seems to work on my end, I get no error messages i'm using unity 2020.3.24f1
I've had a few people have issues with this tutorial.. After helping them out It was normally misspellings in the code.. or them not properly having the layers set up.. I've had this project open in 2021 and 2022 versions of Unity.. If check out Part2 of this tutorial theres a link in the description for the Github page. and on that page theres a UnityPackage you can try importing into a blank project.. You can look around and compare it to yours and see if you can catch the problem.
That's really really cool and easy to use instead of wheel collider! But if you want to implement a braking system instead of start go reverse instantly how do you'd do?
Glad u found it helpful. For that I'd probably lerp the forward motion towards zero with some sort of multiplier.. and then only if the cars forward velocity is zero then you can reverse.. I'll give it a look.. might upload something to my github if I can quickly get it sorta and send u a reply if I can.
You'll have to make sure to follow the steps exactly as they are when setting up the rigidbody, maybe pause it and check.. this means the settings of the inspector and especially the order of things in your scene. if u still have trouble theres a link to the full project on my github page of the 2nd video.. might use it to compare
If you mean the suggestions that pop-up, thats intellisense. Comes with Visual Studio if your IDE is set up for Unity.. heres a link to set it up if thats what ur referring to. docs.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/getting-started-with-visual-studio-tools-for-unity?pivots=windows if its anything else its probably a rider feature.. I'm using Jetbrains Rider for this video.. It's more robust than Visual Studio. www.jetbrains.com/rider/ its subscription based but I was just using the 30 day trial.
@@SpawnCampGames Thanks for your reply. Are you still using Rider? Do you recommend it. It looks pretty good tbh. The small notes next to some of your code look extremely helpful lol.
Hey loved the tutorial😁 Was thinking of turning this script into a F-Zero style hovercraft. How would I got about modifying the script to include airbrakes?, in other works make the ship slowly strafe left or right when the matching trigger is pressed
that'd be easy.. when u AddForce to the sphere you can add in a horizontal strafing speed * your horizontal axis.. or just add it seperately.. rb.AddForce(yourForwardForce); rb.AddForce(yourSidewaysForce);
Not sure. I will say that the way this system works the *setup* of the GameObjects is just as important as the code.. github.com/SpawnCampGames/ArcadeCarController Here is a github link w/ the actual project (as well as the collision part, the 2nd part) You can click the Code button to download a zip file and either open the folder as a new project or use the .unitypackage thats included to just add it to another.. You can use it to compare to yours or just use it as a starting project and work off of it.. I hope you find the issue, good luck 🍀
Oh wow, thank you! Yah I'll compare it. I fixed the bounce, but then the sphere won't move - if I place the sphere in front of the car, the car will go to it when I run the script but not continue to move away from its origin. @@SpawnCampGames
@@teamcollectiveinc2140 I use WASD in the video.. But im grabbing that input using Unity's preset Axis' "Horizontal" and "Vertical" You can find them under Edit> Project Settings> Input Manager default it uses WASD and/or Arrow Keys but you can change the keys to w/e you'd like.. InputAxisRaw returns -1, 0, or 1 InputAxis (without Raw) will return -1 -> 1 but with smoothing already applied.
@@SpawnCampGames Thanks! I thought the car was cycling back and forth independently without key input when you hit the Play button. Is there a tutorial you can point me to for wheel spin?
@@SpawnCampGames end pls help, because I have a small problem, as I did, the same as in the guide and when I am in the car, the same car is moving backwards
@@haskii9088 maybe ur forces are reversed.. check ur input keys.. and swap them around.. or change the forces to negative on the positive one and vice versa.. maybe
Hello SpawnCampGames, thank you for this amzaing tutorial, i have this in my game and the gameplay is awesome. Just one quick improvement that i had to make in order to deal with some bugs when i was driving the car on terrain with some bumps, the gravity part you have on FixedUpdate i changed the "transform.up" for a world space -Y axis so it is always pointing down no matter the cars rotation, other wise the gravity will make a force on the local Y axis of the car wich can lead to some weierd behaviour on irregular terrain when the car is constantly rotating. Cheers!!
Hey mate. Glad to hear! I'm just helping people get a basic understanding and hope they take it from there.. awesome to hear u improving it and customizing it the way u need.. Keep it up
yup same key.. u could for example have the button lerp the speed to 0 at a certain rate... and then once at zero have a bit of a timer to wait Before brake becomes reverse
@@SpawnCampGames that sounds great. I’ve never attempted AI before I was told to use a waypoint system for it though. Never researched into it more but I’m trying to learn more. It’s a process 😂
No mater what im doing the car still desapears into oblivion, all is centrated, pivots are at the same position, but when you hit play it ignores all colliders and go down
@@koushiksai1232 sorry it was more than a year so I dont remember what was the problem. Do you finish to copy the script? I believe it fixed it self when he changed something in the script
When i find time i go back to my old projects and this is one I need to do just that. It has problems with seperate pieces.. The best thing to do is make your terrain / racing course 1 piece.. Ramps and things also should start shallow and then get steeper overall... I'll open it back up and a try to apply some sort of band-aid to prevent it..
@@TETE Started working on my own project and just did a game jam.. I have abunch of videos lined. up just gotta get off my butt and finalize em and get em ready for upload :)
Yes! a simple way I can think is to use a lerp... docs.unity3d.com/ScriptReference/Mathf.Lerp.html add a few extra variables currentSpeed and lerpSpeed.. and adjust it before you pass it into the car's moving logic.. something along the lines of If(Input.GetKey(KeyCode.W) { currentSpeed = Mathf.Lerp(currentSpeed, speed, lerpSpeed); } else { currentSpeed = Mathf.Lerp(currentSpeed, 0f, lerpSpeed); } and then pass currentSpeed into the function instead of speed you had before..
You can simply use an if / else statement and then use the sphere's velocity.. to see if its moving instead of using the key presses.. this is how i would do it if i were to expand it out.. if(sphereRB.velocity.magnitude >= 0.1f) { `steer` } else { `cant steer` }
@@SpawnCampGames That only partially solves the problem as the car will rotate until it comes to a stop but won't actually steer because no force is being applied to its transform.forward. As soon as I saw a system like this a while ago I replicated it and fell into the same trap. There is a simple solution.
Ya'll kept asking so Part 2 is now up.. (Adding Collision)
Check it out :
📺 ruclips.net/video/CpXT5So1Gbg/видео.html
Also find an updated copy of the script used in this video over there in the description..
you are one of the few tutorials that actually takes the time to explain why/how and you deserve applause for it.
Thank you. I try to throw in explanations and tips here and there.. :) It's a balancing act for sure. I could make hour long videos if I broke down everything but I do my best to figure out what are the important bits :)
how do u make it work?i am stiil trying to figure it out but i don no
@@SpawnCampGames listen sir,those hours long doesn't seem long enough😂😂😂you're the best at explaining things
Pls don't stop
This is perfect
I can not tell you enough how much I appreciate this tutorial! You deserve more views!!
Well, thank you!
This is an extremely clean tutorial. The descriptions of everything is incredibly concise and I must say the system design is very good. I do think there might be better ways to handle certain things but nothing can be perfect or match every requirement for each person's project. Excellent job.
So good video but soo less views I am gonna share this to my friends and congratulations for 94 subscribers hope you will get 1k soon
Thank you so much! :)
@@SpawnCampGames no problem but do you use discord I need some help from a professional in unity just small things which I need in my car game I am making
@@sumanojha5310 I do use Discord, although my channel is currently private and invite only.. I can recommend joining the Official Unity Discord. It's a great place to ask for help and I am active there, as well :)
Please keep the good stuff . Love your voice , little jokes and the tutorials . Good job!!!!
Well, Thank you fam! I personally don't like the way I sound but I think that's the case with us all. xD.. I try to joke and keep the material fun because that's the way it should be.. Gotta be enjoying what you do!! :) But anyways, thanks for the shoutout and thanks for watching..
Really appreciate the visual explanations. I taught the only way to create car controllers in unity was by using wheel colliders. Thanks for the insight!
ive been looking for a whole week and the only good tutorial i found is this one. DEfinietly subbing
Thanks man, this is what I have been looking for about 1 month. You are genius bro. Thanks again for such a detailed and well explained tutorial. You deserve much more.
Absolutely phenomenal tutorial. People like you are what make RUclips worth visiting. Thank you so much
Woaw that's very cool
-Dani
Your explanation and the simplicity of the code is perfect. thanks for the tutorial dude
After Doing Some Tweaks It Works Like A Charm Love Your Tutorials Man
This was an incredible tutorial with a genius approach. Keep up the awesome work
This is exactly what I was looking for! You a real one!
I like it that you call the bin "SHIT"
Hehe ;) Good Eye
THANK YOU, Ive had so much trouble making a working car. This is so helpful!
You are literally a lifesaver! This tutorial is amazing!!!
your the best coder i ever saw
Wow, this was amazing. I did not expect something like this to work so quickly! Thanks!
This is amazing, thx for this dude.
Such AMAZING tutorial! Lots of explanations! Thanks ;)
Thanks, I've been searching for this type of controller for long time
This is literally AMAZING the only thing that makes it not so viable is the way the car follows normals of the road via using raycast. if it went straight up a 45 degree angle it snaps to the normals resulting in an akward transition.
Thanks! and yes it could use some ironing out and I hope to make a part 2 soon. Lerping between the rotations would make a nicer transition..
@@SpawnCampGames also a tutorial for sound would be extraordinarily useful
@@PricelessCold also queued up ;)
"There's one problem. The car turns while sitting still."
Me, who's here for a drifting tank controller: _Nice._
I have a prob can you send me the script?
Many thanks for this, it is awesome! One little thing I would say is that if you are not accelerating (either forward or backwards) then you can't turn the car, but is the only thing I saw missing. Awesome job!!
there's a part 2 coming out with better turning.. and collision :)
@@SpawnCampGames where is iitttt? :(
@@Joanarkj sorry its been hectic.. and i'm working on a game of my own part time.. I havent forget and I've got 3 videos in the works..
I really appreciate it man! Keep up the good work!
Oh damn, this works!! Thanks a lot, man, amazing tutorial!!!
Lol.. why wouldn't it? 😅
You're really good. Thank you for this tutorial.
Cool tutorial, really nice work...but i have problem colliding with walls, the car goes inside or the wall until he reach the sphere colider any ideas for that?
*"he"* pronoun for a car
The part 2 of the video covers collisions. Link in video description.
oh WAIT
what a co-incidence we have the same NUMBER OF SUBSCRIBERS OMG
Really nice system but my only concern is how quickly the car accelerates and deaccelerates. How can you get it to ramp up to top speed slower and and come to a stop longer when not on the throttle?
best tutorial ever, 10u so much
i really loved ur tut bro keep it up and u really deserve more subs btw im ur subscriber
I appreciate it!
@@SpawnCampGames Thank you it made my day
Life saver! Subscribed!!!!!
if someone has problems in physics in 7 minute just dont worry make everything like in video and in 13 minute everything will be working properly.
i like it, but the rotation isn't smooth when going up a ramp. i have tried to lerp it, but then i can't steer. can you help me?
Loved the tutorial. I used it to build a quick car controller but I had an issue that when I stopped pressing forward/backwards I lost my turning. So I swapped in a DOT product and stopped using the moveInput for the steering. Here are my changes :)
float turnStepVelocity = Vector3.Dot(transform.forward, (SphereRB.position + SphereRB.velocity - SphereRB.position).normalized);
float turnStep = turnInput * turnSpeed * Time.deltaTime * turnStepVelocity;
transform.Rotate(0, turnStep, 0, Space.World);
// float turnStep = turnInput * turnSpeed * Time.deltaTime * moveInput;
// transform.Rotate(0, turnStep, 0, Space.World);
Tks so much for this tutorial, I had some issue due the Visual Studio update but in the end I could finish this tutorial. I was thinking how to disable the rotation when the car is on the ground.
bro i really dont understand what do you did to make the car stop bouncig on the start of the video im using another car model and it keeps bouncing plz explaing in another video how u doit
actually i figured out, i put the "transform.position = sphereRB.transform.position;" on the fixed update since the pivot points of the sphere and the car was in the same exact place and they dont stop bouncing
@@morpog64 fucken godsend thank you so much
you're a genius my guy
tx
Hi SpawnCampGames really good tutorial! Can you please tell me how you can get the car skidding a bit more when acceleration is released, it seems to stop turning too quick.
Hey,
I have a request, if you could do a part 2 about collisions(Solving the issue with parts of the car entering objects). Whilst it might seem simple, Ive tried many things and its just not working!
Keep an eye out ;)
this idea is awesome. Inspiring me so much!
spawncampgames.github.io/project/drift/ArcadeCarV2.png
I'm glad that I can be of some inspiration :) :)
Working on Part2 as we speak.
Do you have the sample code/script somewhere... I'm trying to figure something???
you move the sphere forward/backward?
do you turn the sphere? I just see you turning the car parent empty gameobject??? So how does the sphere change the direction it goes in for the rest to follow???
I have this project up on github.com/SpawnCampGames/ArcadeCarController github
Please make a chase camera for the car!Please
Thanks, this approach looks very practical. Does the car roll down a hill by itself (and pick up speed)?
Hi I am at 11:09 in the video and my sphere is moving but not the actual car model. How do I fix this? Great Tutorial BTW
Thank you, I liked your channel
Thank you my friend works like a charm
Is it possible to set up a more accurate collider for the mesh of the car, to crash with other cars or walls, I can't figure out how to make the collisions from the car affect the sphere.
this is an arcade controller really meant to be viewed top down and have bumping type collisions.. really accurate collisions aren't really something i know how to achieve with this controller.. altho I have been experimenting with collisions and I have a part 2 for this video coming out.. This uses a simple box collider and another rigidbody thats seperate from the car.. and sets its position to match the sphere and rotation to match the car..
Example:
gfycat.com/orderlysatisfiediberianlynx
I adjusted the pivot for the sphere and the car so that its at the same point just like you did, the transform of the sphere is also 0,0,0 but still the car just bounces and falls below the platform.
If your using the same car asset:
The Car will be @ 0, 0.5, 0
The Car graphics will be @ 0, -0.5, 0
The Sphere will be @ 0, 0, 0
If you pull the sphere outside of the Car gameobject their transforms should match..
When the car is assembled in the way of the video their transforms will not match..
@@SpawnCampGames Apparently there was a problem while I made the sphere car's child. It works now, thanks!
@@nishantdesai5064 I'm facing the same issue. What did you do to solve?
How Did You Do It?
@@anupamverma7677 bro I had the same problem, don't really know how but i somehow fixed it I think, believe you just have to be very precise with the pivot point
Haven't finished the video yet but have yet to see an explanation. Why use a sphere? Because of the collider?
waouh just awesome !!!
thank you very much
I don't understand how you got the bouncing to stop?
Hey @SpawnCampGames I am struggling with getting the pivots of the CarBody to line up with the MotorSphere.
I tried to manually change the rotation of my kart mash through Blender so the rotation (X, Y, Z) was all set to 0. I also tried putting the kart in an empty model set in the same location as the MotorSphere. Note that I am using my own model. Not a marketplace model.
What can I do to manually set the pivot point to where I want so the vehicle doesn't fling into oblivion?
Yea, its a thing you just need to fine tune until you get it right.. I could suggest just using primitive shapes like a normal ole unity cube and get that working and then change out the cube for ur artwork..
If it will help I have the project on Github github.com/SpawnCampGames/ArcadeCarController
you can click the Green Code button in the top right corner and download the zip file.. Its a normal Unity project. so you can extract it to a new folder and open the project up in Unity..
could use it as an example to help ya out..
@@SpawnCampGames Okay I'll look at it. Thanks for the help.
Surprised you don't have more followers very clear and alot of explanation and ur not typing at lightning speed so I'm actually able to follow along and not pause every 5 seconds xD
Two questions though one why didn't you just unchild the motor sphere in the editor instead of script was it just to keep everything together/more clean
And two how did you get those extra things in ur code like it says what the different variables are like the x y and z or the origin and direction in the ray cast there in gray letters I have the auto complete thing installed but I don't get stuff like that?
Hope you have a great day
The reason I don't unparent the Motor sphere in the editor is because this way you can keep them together as a prefab, and drag it around to a good starting position.
The things you see are called inline tips/hints. ruclips.net/video/XE5q8A5vz3k/видео.html
I have a video explaining how to turn them on. They're great for beginners so you can understand your code better. But personally I use them often when I write out a function of something that takes in many arguments
for example if i have:
public void SetUpSkybox(Color colorOfSky, float intensityOfLight)
when I go to type out the function it'll help me know what belongs there.. and also it allows me to quickly glance at functions and know whats being passed in w/o me having to track down the function..
@@SpawnCampGames oh awesome! ya I was thinking those would save me a trip to Google when writing the more complex functions
How can i turn the car depending on speed? While standing car should not move. I don't like to press forward or backwards to steer this.
Super! How would I tackle things such as maxSpeed, acceleration, deceleration and drifting?
Hi, because I have a small problem, as I did, the same as in the guide and when I am in the car, the same car is moving backwards
Great video. But is there a way to make the car turn while not going forward?
Why, yes.. If you check out the video @ 13:16 You'll see the code before I modified it to only turn while moving forwards and backwards...
The reason I did it that way is because it sorta turns into a TOP and just spins in place :D...
If you are talking about turning the car with w/e momentum is left over from accelerating, there are ways to do it but I chose not to for this video because of the nature of the car controller..
( This video has gotten a lot of attention so I most likely am going to do a Part 2 where we add onto it. And I'll remember your question when I do :) )
@@SpawnCampGames You`re awesome. thank you.
Have you stopped making videos? I'd like to subscribe see more videos ?!
If you subscribe I'll start on a new video Today! :)
let me know what ud like to see
@@SpawnCampGamesI've subbed... the new unity Versions have new features like HDRP clouds and water.. Id like to see a couple of videos on them?
@@random_precision_software
ok coool, I just started getting into URP for my new Space Adventure game I'm currently working on but I haven't done much with either... Would be a good chance for me to learn some things as well..
The next video probably won't be URP or HDRP since I have to get familiar with it myself first.. BUT a promise is a promise.. And I'm starting a brand new project as I type. :) Thanks for the SUB.. check in tomorrow or the next day (at the latest) for a new video :) :) :) happy developing
@@SpawnCampGames look forward to it!
just hit the editing floor :)
Omg wow thank you so much for this tutorial!! I was trying to make a simple racing game and I tried using wheel colliders but I kept having so many weird bugs, this was so easy and clear and this might have saved my project!!
Is there a Input.GetKey method foor adding force?
The same Input.GetKeyDown would be what you use in any scenario. The rest of the code wouldn't matter
docs.unity3d.com/ScriptReference/Input.html
Note, Rigidbody movement should usually be done in the FixedUpdate(). If you put Input in there some of it may be missed because the FixedUpdate() runs at a much slower frame rate.
Although, it doesn't seem to stop them in examples:
docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html
I'm so close to getting this working. I'm stuck at about 15:30. My car moves much slower and all the setting are correct. The car is not going fast enough to go off the jump. And when it hits the jump the SphereMotor jumps out of the car and everything goes crazy. I can't figure out what's different!
I figured out the speed problem for all those doing this tutorial. The ARCADE Car Asset has been updated and some of the prefab cars have wheel colliders. They need to be deleted and the speed will be correct.
Problem SOLVED! You have to make sure to use the Prefab car and NOT the Prefab car with Colliders
Hello, this is awesome and so simple. Thank you. I would like to ask for a little help tho regarding streering, how would i approach steering whie decelerating, so the input to forward is no longer active, but the car still carries the initial momentum and i would like to be able to steer in the time window before complete stop.
oh, i found, a question like this that you already answered. :)
@@milanmolnar3820 true.. but I only glossed over it.. I'm actually workin on a part two with better steering collision and extras :) stay tuned if u wanna check it out!
spawncampgames.github.io/Drift/
here's a quick web build i threw up.. I'm still tweaking with the steering but I'm assuming this is similar to what you're asking for..
@@SpawnCampGames Thanks :)
Excelent! it is very useful!
One question, why do you multiply by * transform.rotation at minute 18:26?
Thanks for the timestamp.. We need to multiply it by its own transform to apply it to our 'FromToRotation' quaternion rotation. Quaternions are magic.. and multiplying a quaternion isn't the same as actually multiplying it.. To be completely honest I've been doing Unity for quite a while now and still can't explain them..
forum.unity.com/threads/quaternion-rotation-along-normal.22727/
The 2nd post also explains why this is done.. Sorry I can't break it down in a good way :D
@@SpawnCampGames many thanks!
Very nice! Thanks for sharing! Is there an easy way to smoothly rotate the car as it enters a ramp and also when it lands? Rather than suddenly jerking the rotation, maybe lerping it to the same rotation as the ramp?
yup.. i would just lerp it or slerp it perhaps, towards its new value..
@@SpawnCampGames I'll give it a go tomorrow, thanks for the reply!
Nice controller 💥
Anyone know why I need to crank the values up to get any speed, the values in this video still go slow? I'm wondering if theres a reason why this is occuring.
In Unity when you are dealing with Physics values, they tend to be very high.. in the thousands. If you are translating.. (moving the objects with its transforms) you can use smaller values.. because its like units per second.. a Unit is a big area in Unity.. (a meter)
you can also mess with the physics materials that you apply to things.. as well as the drag and angular drag
hi! i have a problem with the script at 9:15 ; my car doesn't want to move , i don't find errors and i retype the script but it's the same, can you help me please ? thanks !
Try disabling the "Static" checkbox in the CarModel game object.
Do you still have this problem?
@@artursponchiado7265 I have Static uncheck but still not move
Hey, so I ran into a problem, so I have the camera follow the car but when it turns, the camera faces the front of the car and I always want it to be following the back of the car. Any help?
I use the Cinemachine package from Unity.. super simple to set up a good follow camera with that practically drag and drop..
or u could just track the cars transform and add an offset to put it behind the car.. but the way it drifts probably would be kinda disorienting..
Any time my car goes on a ramp it thinks that it's not grounded and I lose control, the ramp is identical to what you used and on the groundlayer mask
Try debugging what the Raycast is hiting..
I'd also say make sure your Raycast is long enough to reach the ramp..
Another good way of troubleshooting is by using OnGizmoSelected method or similar and its DrawRay function to redraw your Raycast in the editor window to make sure its where you'd expect it to be.
Theres a part two where we redo the car and also a link to a project file that you could compare to.
Maybe one of the two would also be useful to help you figure out where the problem is.
@@SpawnCampGames Thanks for the advice, I made the raycast 1.5f long and that fixed the issue, I followed the second guide aswell.
Guys, please help, my car is constantly slowly goes back, when there is no moveInput.
Removing Rigitbody from Car model helped.
set ur drag to 1
good work
for some reason my scene isn't behaving like ur scene, first difference when I added the sphere to the car it doesn't bounce at all it just falls straight down once I start the game. After I followed everything in the video private void FixedUpdate()
{
sphereRb.AddForce(transform.forward * moveInput, ForceMode.Acceleration);
} this script doesn't allow my car to move even though I properly referenced it and set force to 200 in inspector.
I'm at time 9:00 and nothing seems to work on my end, I get no error messages
i'm using unity 2020.3.24f1
I've had a few people have issues with this tutorial.. After helping them out It was normally misspellings in the code.. or them not properly having the layers set up.. I've had this project open in 2021 and 2022 versions of Unity.. If check out Part2 of this tutorial theres a link in the description for the Github page. and on that page theres a UnityPackage you can try importing into a blank project.. You can look around and compare it to yours and see if you can catch the problem.
@SpawnCampGames awesome. Thank you for responding in such a timely manner. I'll let you know if it works or if there's any difference
You have to disable the "Static" checkbox in the CarModel game object.
Is there any way to add a collision into the car? I'm trying but it's not working..
Great tutorial btw!
I'm workin on a part 2.. will include collision
@@SpawnCampGames looking forward to it
Thanks!
Thank you!
i have my car like floating and the sphere is under the car everytime i play how can i fix it?
That's really really cool and easy to use instead of wheel collider! But if you want to implement a braking system instead of start go reverse instantly how do you'd do?
Glad u found it helpful. For that I'd probably lerp the forward motion towards zero with some sort of multiplier.. and then only if the cars forward velocity is zero then you can reverse.. I'll give it a look.. might upload something to my github if I can quickly get it sorta and send u a reply if I can.
@@SpawnCampGames Thanks for the reply, that's a good idea. I'll check your github then, that would be great!
How do you can move the model with CTRL? Did you set up the shortcut? And My car still fall off the ground.
And how do you move the car?
You'll have to make sure to follow the steps exactly as they are when setting up the rigidbody, maybe pause it and check.. this means the settings of the inspector and especially the order of things in your scene. if u still have trouble theres a link to the full project on my github page of the 2nd video.. might use it to compare
@@SpawnCampGames Btw, I’m using the code in 2nd video. I wonder if you can make car drift by using brake input like Brake to Drift mechanic.
Hey man great tutorial. I noticed you have small tooltips next to certain blocks of code. How do you enable them please?
If you mean the suggestions that pop-up, thats intellisense. Comes with Visual Studio if your IDE is set up for Unity..
heres a link to set it up if thats what ur referring to.
docs.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/getting-started-with-visual-studio-tools-for-unity?pivots=windows
if its anything else its probably a rider feature.. I'm using Jetbrains Rider for this video.. It's more robust than Visual Studio.
www.jetbrains.com/rider/
its subscription based but I was just using the 30 day trial.
@@SpawnCampGames Thanks for your reply. Are you still using Rider? Do you recommend it. It looks pretty good tbh. The small notes next to some of your code look extremely helpful lol.
this is awesome
For some reason the term 'Rigidbody' along with many of the things he writes doesn't change color for me, can anyone tell me how to fix that?
need to configure ur IDE.. just search Configure "your software" for Unity
@@SpawnCampGames ok thanks
how are you getting the suggestion while typing , i never get
please tell
Hey loved the tutorial😁
Was thinking of turning this script into a F-Zero style hovercraft. How would I got about modifying the script to include airbrakes?, in other works make the ship slowly strafe left or right when the matching trigger is pressed
that'd be easy.. when u AddForce to the sphere you can add in a horizontal strafing speed * your horizontal axis..
or just add it seperately..
rb.AddForce(yourForwardForce);
rb.AddForce(yourSidewaysForce);
I'm half way through the video, I have the script copied exactly, but the car won't move when I hit play. What am I doing wrong?
Not sure. I will say that the way this system works the *setup* of the GameObjects is just as important as the code..
github.com/SpawnCampGames/ArcadeCarController
Here is a github link w/ the actual project (as well as the collision part, the 2nd part)
You can click the Code button to download a zip file and either open the folder as a new project or use the .unitypackage thats included to just add it to another..
You can use it to compare to yours or just use it as a starting project and work off of it..
I hope you find the issue, good luck 🍀
Oh wow, thank you! Yah I'll compare it. I fixed the bounce, but then the sphere won't move - if I place the sphere in front of the car, the car will go to it when I run the script but not continue to move away from its origin. @@SpawnCampGames
WAIT. I just realized it works if I use the forward/back arrow keys. 🤦♀
@@teamcollectiveinc2140 I use WASD in the video.. But im grabbing that input using Unity's preset Axis' "Horizontal" and "Vertical" You can find them under Edit> Project Settings> Input Manager
default it uses WASD and/or Arrow Keys but you can change the keys to w/e you'd like..
InputAxisRaw returns -1, 0, or 1
InputAxis (without Raw) will return -1 -> 1 but with smoothing already applied.
@@SpawnCampGames Thanks! I thought the car was cycling back and forth independently without key input when you hit the Play button. Is there a tutorial you can point me to for wheel spin?
you explain well
Amazing tutorial, but how did you get all the wheels to turn with the car?
They don't curently, but I'll add this in Part 2 :)
@@SpawnCampGames Ah, must had been the bitrate messing with my eyes. Thanks, I'm looking forward to it.
Hey generally make yourself asked where do you write these codes? in which program?
I use either Visual Studio 2019, or Jetbrains Rider.. which has a free evaluation...
@@SpawnCampGames thanks
@@SpawnCampGames end pls help, because I have a small problem, as I did, the same as in the guide and when I am in the car, the same car is moving backwards
@@haskii9088 maybe ur forces are reversed.. check ur input keys.. and swap them around.. or change the forces to negative on the positive one and vice versa.. maybe
@@SpawnCampGames o thanks you
Hello SpawnCampGames, thank you for this amzaing tutorial, i have this in my game and the gameplay is awesome. Just one quick improvement that i had to make in order to deal with some bugs when i was driving the car on terrain with some bumps, the gravity part you have on FixedUpdate i changed the "transform.up" for a world space -Y axis so it is always pointing down no matter the cars rotation, other wise the gravity will make a force on the local Y axis of the car wich can lead to some weierd behaviour on irregular terrain when the car is constantly rotating.
Cheers!!
Hey mate. Glad to hear! I'm just helping people get a basic understanding and hope they take it from there.. awesome to hear u improving it and customizing it the way u need.. Keep it up
Is the brake reverse?? The road assets in low poly are quality
yup same key.. u could for example have the button lerp the speed to 0 at a certain rate... and then once at zero have a bit of a timer to wait Before brake becomes reverse
@@SpawnCampGames would be a great idea. Also was thinking of an e-brake so you can hit it and sharply turn or something like that.
@@CarlJT good suggestion if i can find the time ill probably do a part 3 and add even more features.. maybe an ai car too
@@SpawnCampGames that sounds great. I’ve never attempted AI before I was told to use a waypoint system for it though. Never researched into it more but I’m trying to learn more. It’s a process 😂
No mater what im doing the car still desapears into oblivion, all is centrated, pivots are at the same position, but when you hit play it ignores all colliders and go down
Never mind this problem fixed later in the script, for some reason unity it just dont works exactly like yours
How did u fix it??pls tell me
@@koushiksai1232 sorry it was more than a year so I dont remember what was the problem. Do you finish to copy the script? I believe it fixed it self when he changed something in the script
Sphere collider catching edges of aligned cubes
When i find time i go back to my old projects and this is one I need to do just that. It has problems with seperate pieces.. The best thing to do is make your terrain / racing course 1 piece.. Ramps and things also should start shallow and then get steeper overall... I'll open it back up and a try to apply some sort of band-aid to prevent it..
So, I'm sure, When you travel over two pieces that are connected it hits it and does a little bounce?
@@SpawnCampGames yeas exactly
@@SpawnCampGames your tutorials are actually so good and why did you stop making those
@@TETE Started working on my own project and just did a game jam.. I have abunch of videos lined. up just gotta get off my butt and finalize em and get em ready for upload :)
good asset
Very good tutorial!
It would be cool if we could download the script
Is there any way for the car to gradually gain speed? Thanks for the video, amazing !
Yes! a simple way I can think is to use a lerp...
docs.unity3d.com/ScriptReference/Mathf.Lerp.html
add a few extra variables currentSpeed and lerpSpeed.. and adjust it before you pass it into the car's moving logic..
something along the lines of If(Input.GetKey(KeyCode.W)
{
currentSpeed = Mathf.Lerp(currentSpeed, speed, lerpSpeed);
}
else
{
currentSpeed = Mathf.Lerp(currentSpeed, 0f, lerpSpeed);
}
and then pass currentSpeed into the function instead of speed you had before..
@@SpawnCampGames Thank you man! Stay safe!
thanks, you too friend!
nice but if you are coasting to a halt but not applying forward input the car wont steer.
You can simply use an if / else statement and then use the sphere's velocity.. to see if its moving instead of using the key presses.. this is how i would do it if i were to expand it out..
if(sphereRB.velocity.magnitude >= 0.1f)
{ `steer` }
else
{ `cant steer` }
@@SpawnCampGames That only partially solves the problem as the car will rotate until it comes to a stop but won't actually steer because no force is being applied to its transform.forward.
As soon as I saw a system like this a while ago I replicated it and fell into the same trap.
There is a simple solution.
My Car Does Not Stop Bouncing Even After Changing The Coordinates Of The Sphere