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 » Scripting Helpers
Home Search
 

Re: Velocity help

Previous Thread :: Next Thread 
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Apr 2012 02:48 PM
I'm currently developing a flight suit, and I cannot figure out how to make the player fly in the direction where your mouse is pointing! This is what I have so far.

while game.Players.LocalPlayer.Character == nil do
wait()
end
wait(1)
local mouse
local Colors
local Velocity
local BVelocity
local Gyro
local Colors = game.Players.LocalPlayer.Character:FindFirstChild("Body Colors"):Clone()
function onEquipped(m)
Colors = game.Players.LocalPlayer.Character:FindFirstChild("Body Colors"):Clone()
game.Players.LocalPlayer.Character:FindFirstChild("Body Colors").HeadColor = BrickColor.new("Dark stone grey")
game.Players.LocalPlayer.Character:FindFirstChild("Body Colors").LeftArmColor = BrickColor.new("Dark stone grey")
game.Players.LocalPlayer.Character:FindFirstChild("Body Colors").RightArmColor = BrickColor.new("Dark stone grey")
game.Players.LocalPlayer.Character:FindFirstChild("Body Colors").RightLegColor = BrickColor.new("Dark stone grey")
game.Players.LocalPlayer.Character:FindFirstChild("Body Colors").LeftLegColor = BrickColor.new("Dark stone grey")
game.Players.LocalPlayer.Character:FindFirstChild("Body Colors").TorsoColor = BrickColor.new("Dark stone grey")
game.Players.LocalPlayer.Character:FindFirstChild("Head").Material = "Foil"
game.Players.LocalPlayer.Character:FindFirstChild("Torso").Material = "Foil"
game.Players.LocalPlayer.Character:FindFirstChild("Left Arm").Material = "Foil"
game.Players.LocalPlayer.Character:FindFirstChild("Right Arm").Material = "Foil"
game.Players.LocalPlayer.Character:FindFirstChild("Left Leg").Material = "Foil"
game.Players.LocalPlayer.Character:FindFirstChild("Right Leg").Material = "Foil"
Velocity = Instance.new("BodyVelocity",game.Players.LocalPlayer.Character.Head)
Velocity.velocity = Vector3.new(0,0,0)
Velocity.P = 1250
Velocity.maxForce = Vector3.new(4000, 4000, 4000)
Velocity.Name = "BodyVelocity"
Velocity.Archivable = false
BVelocity = Instance.new("BodyAngularVelocity",game.Players.LocalPlayer.Character.Head)
BVelocity.P = 1250
BVelocity.angularvelocity = Vector3.new(0,0,0)
BVelocity.maxTorque = Vector3.new(4.000e+005,4.000e+005,4.000e+005)
BVelocity.Name = "BodyAngularVelocity"
BVelocity.Archivable = false
Gyro = Instance.new("BodyGyro",game.Players.LocalPlayer.Character.Head)
Gyro.D = 500
Gyro.P = 3000
Gyro.Name = "BodyGyro"
Gyro.Archivable = false
Gyro.maxTorque = Vector3.new(4.0000e+005,4.0000e+005,4.0000e+005)
Gyro.cframe = game.Players.LocalPlayer.Character.Head.CFrame
mouse = m
mouse.Button1Down:connect(Click)
end
script.Parent.Selected:connect(onEquipped)

function unEquipped()
game.Players.LocalPlayer.Character:FindFirstChild("Body Colors"):Destroy()
Colors.Parent = game.Players.LocalPlayer.Character
game.Players.LocalPlayer.Character:FindFirstChild("Head").Material = "Plastic"
game.Players.LocalPlayer.Character:FindFirstChild("Torso").Material = "Plastic"
game.Players.LocalPlayer.Character:FindFirstChild("Left Arm").Material = "Plastic"
game.Players.LocalPlayer.Character:FindFirstChild("Right Arm").Material = "Plastic"
game.Players.LocalPlayer.Character:FindFirstChild("Left Leg").Material = "Plastic"
game.Players.LocalPlayer.Character:FindFirstChild("Right Leg").Material = "Plastic"
if Velocity ~= nil then
Velocity:Destroy()
end
if Gyro ~= nil then
Gyro:Destroy()
end
if BVelocity ~= nil then
BVelocity:Destroy()
end
end
script.Parent.Deselected:connect(unEquipped)

function Click()
Velocity.velocity = CFrame.new(game.Players.LocalPlayer.Character.Head.CFrame.p):pointToWorldSpace(Vector3.new(mouse.Hit))
Gyro.cframe = CFrame.new(game.Players.LocalPlayer.Character.Head.CFrame,mouse.Hit)
end
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Apr 2012 08:48 AM
Bump
Report Abuse
PvcPipe is not online. PvcPipe
Joined: 21 Jul 2010
Total Posts: 68
25 Apr 2012 09:03 AM
I've had the same problem trying to find the mouse. It is not fun at all. Let me get you a few useful links though.
http://wiki.roblox.com/index.php/Mouse -- that tells you how to get the mouse.
and I cant find the page, but I think you can do: mouse.CFrame.lookVector
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Apr 2012 09:25 AM
I never thought of getting the mouse's lookVector, thanks!
Report Abuse
PvcPipe is not online. PvcPipe
Joined: 21 Jul 2010
Total Posts: 68
25 Apr 2012 09:36 AM
If it works, reply back as I'm not sure how to get it to work.
Report Abuse
myrEIGHT is not online. myrEIGHT
Joined: 22 Apr 2012
Total Posts: 124
25 Apr 2012 09:50 AM
Direction = cam.CoordinateFrame.p-Mouse.Hit.p
Direction = Direction / Direction.magnitude
WantedPosition = OldPosition+Direction*STEP

Basicly /cam.CoordinateFrame.p/ can be any vector3,
which will rule the direction from point A (cam.CoordinateFrame.p currently) to mouse target point.
WantedPosition will be the next position to the direction from oldposition.
If you're using body objects use Direction*Speed as velocity
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Apr 2012 11:05 AM
I only needed the mouse lookVector...

Anyways, how would I get the perpendicular angle to a unit vector?
Report Abuse
stroudie is not online. stroudie
Joined: 28 Nov 2008
Total Posts: 2556
25 Apr 2012 11:17 AM
How come this won't work guys?

e = game.Players.LocalPlayer.Character.Torso.CFrame.lookvector
print(e)

It just tells me that i'm referring to a nil value :/
CFrame.p works fine, why not lookvector though?
Report Abuse
PvcPipe is not online. PvcPipe
Joined: 21 Jul 2010
Total Posts: 68
25 Apr 2012 11:22 AM
stroudie, I think it is "lookVector" or "LookVector" not "lookvector"
Report Abuse
stroudie is not online. stroudie
Joined: 28 Nov 2008
Total Posts: 2556
25 Apr 2012 11:28 AM
Tried them all.
Report Abuse
stroudie is not online. stroudie
Joined: 28 Nov 2008
Total Posts: 2556
25 Apr 2012 11:33 AM
Nevermind, it's lookVector.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
25 Apr 2012 11:47 AM
@thread creator

That would be your 'lookVector'
Since it's just a direction duh..


-myrEIGHT
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Apr 2012 02:50 PM
I know, but how do I get a perpendicular angle to a unit vector?
Report Abuse
blocker192 is not online. blocker192
Joined: 13 Jan 2010
Total Posts: 496
08 Jun 2013 10:53 AM
Hm
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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