- Home /
How can I know when to instantiate skidmarks in a car game
I'm doing a car game and Id like to know if there is any way to see if the car is skidding or going sideways or when I have to instantiate the skidmarks.
Answer by KazeEnji · Jan 09, 2013 at 09:51 PM
I'm assuming you have some variable measuring speed yes? At least for the skidding you could say something like:
function GetMouseDown()
{
break=true;
}
function GetMouseUp()
{
break=false;
}
function Update()
{
if(speed > *a certain speed* && brake==true)
{
*Being creating the skid marks*
}
}
As for determining skidding if you've turned a certain degree at a certain speed it would be similar to what I just wrote except you would want to add in a rotation measurement.
so in the Update function you could monitor the change in rotation of your car...so something like:
function Update()
{
if(startRotation-currentRotation >= *whatever number*)
{
*Begin creating skidmarks*
}
}
And at some point you'll also have to update the startRotation value so it doesn't skid on you constantly because you turned a corner or something from the start of the map.
Hope that at least gets you going in the right direction! -Kaze-
Your answer
Follow this Question
Related Questions
Perfect friction with WheelColliders 1 Answer
Simulating wheels without a wheel collider? 1 Answer
Wheelcolliders stuck in ground 0 Answers
RigidBody2D trap inside a circle 1 Answer
Add colliders without affecting rigidbody behaviour? 2 Answers