austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
|
| 29 Jan 2015 04:55 PM |
I have this script here: _________________________________________________
local skidthreshhold = 2 -- the amount you want your car to skid before the tires start smoking.
local smoke = script.Parent.Smoke
local tiresqueal = script.TireSqueal
tiresqueal:Play()
while true do wait (0.001)
local z = script.Parent.Velocity.x
if z < 0 then zp = z * -1 else zp = z end
if zp > skidthreshhold then tiresqueal.Volume = 1 smoke.Enabled = true else tiresqueal.Volume = 0 smoke.Enabled = false end end
_________________________________________________
It works, but it doesn't detect the x direction locally.
If I drive my car in the X direction, it makes the slide sound. I want it to where it plays the slide sound only when the car slides sideways (x) direction.
Is this possible?
|
|
|
| Report Abuse |
|
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
|
| 29 Jan 2015 05:19 PM |
| I really need help, please. |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 29 Jan 2015 05:31 PM |
Just guessing here but you could try something like this and play with the threshold
threshold = 15
RightVector = script.Parent.CFrame.lookVector * CFrame.Angles(0,math.pi/2,0) Velocity = script.Parent.Velocity
dot = RightVector:Dot(Velocity)
if dot <= 0.7 * Threshold or dot >= -0.7 * Threshold then --playsound end
|
|
|
| Report Abuse |
|
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
| |
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 29 Jan 2015 05:41 PM |
| RightVector = (script.Parent.CFrame * CFrame.Angles(0,math.pi/2,0)).lookVector |
|
|
| Report Abuse |
|
|
Drake1458
|
  |
| Joined: 26 Nov 2008 |
| Total Posts: 4191 |
|
|
| 29 Jan 2015 05:47 PM |
| Distance over time in your relative position. |
|
|
| Report Abuse |
|
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
| |
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 29 Jan 2015 05:59 PM |
I made a little test in the studio using what I wrote and it works okay-ish I guess.
Make the >= a <= and vice-versa and make sure it's all in a while loop.
I'm out of ideas otherwise :-( |
|
|
| Report Abuse |
|
|
|
| 29 Jan 2015 06:05 PM |
| If you mean you want to to calculate from the parts x axis, then you would use CFrames. |
|
|
| Report Abuse |
|
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
|
| 29 Jan 2015 06:23 PM |
| Can you show me an example? |
|
|
| Report Abuse |
|
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
|
| 30 Jan 2015 04:54 PM |
@RolfBread
I modified your code. It kinda worked. It played the sound when the car wasn't sliding, I think it is because the <= and >= were backwards and they were. But now, it won't even play the sound no matter how hard I drift. _____________________________________________________________________
smoke = script.Parent.Smoke
tiresqueal = script.TireSqueal
tiresqueal:Play()
Threshold = 15
RightVector = (script.Parent.CFrame * CFrame.Angles(0,math.pi/2,0)).lookVector Velocity = script.Parent.Velocity
dot = RightVector:Dot(Velocity)
if dot >= 10.0 or dot <= -10.0 then tiresqueal.Volume = 1 smoke.Enabled = true else tiresqueal.Volume = 0 smoke.Enabled = false end |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 30 Jan 2015 05:30 PM |
| Hmm. Try adding some prints in there to see what the dot variable's value is when you drift / when you're not. |
|
|
| Report Abuse |
|
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
|
| 30 Jan 2015 05:32 PM |
| I tried changing the DOT to like 0.00000001 to maybe 1000 and still won't detect side movement. However when it is set to 0.0 is starts playing the sound. |
|
|
| Report Abuse |
|
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
| |
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
|
| 29 Jul 2015 12:20 PM |
| It's been a while and I still can't figure this out. |
|
|
| Report Abuse |
|
|
austint30
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 1482 |
|
|
| 29 Jul 2015 12:22 PM |
| Does anyone know of a car model out there that does make skid sounds? I could probably copy the code from that. |
|
|
| Report Abuse |
|
|