generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How to get LOCAL velocity of an object?

Previous Thread :: Next Thread 
austint30 is not online. 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 is not online. austint30
Joined: 20 Mar 2010
Total Posts: 1482
29 Jan 2015 05:19 PM
I really need help, please.
Report Abuse
RoflBread is not online. 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 is not online. austint30
Joined: 20 Mar 2010
Total Posts: 1482
29 Jan 2015 05:38 PM
Doesn't work.
Report Abuse
RoflBread is not online. 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 is not online. Drake1458
Joined: 26 Nov 2008
Total Posts: 4191
29 Jan 2015 05:47 PM
Distance over time in your relative position.
Report Abuse
austint30 is not online. austint30
Joined: 20 Mar 2010
Total Posts: 1482
29 Jan 2015 05:48 PM
Doesn't work still.
Report Abuse
RoflBread is not online. 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
earthyreuben is not online. earthyreuben
Joined: 17 Jan 2010
Total Posts: 669
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 is not online. austint30
Joined: 20 Mar 2010
Total Posts: 1482
29 Jan 2015 06:23 PM
Can you show me an example?
Report Abuse
austint30 is not online. 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 is not online. 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 is not online. 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 is not online. austint30
Joined: 20 Mar 2010
Total Posts: 1482
30 Jan 2015 05:33 PM
even at idle
Report Abuse
austint30 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image