|
| 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 |
|
|
| |
|
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 |
|
|
|
| 25 Apr 2012 09:25 AM |
| I never thought of getting the mouse's lookVector, thanks! |
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
| |
|
stroudie
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
|
| 25 Apr 2012 11:33 AM |
| Nevermind, it's lookVector. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 25 Apr 2012 02:50 PM |
| I know, but how do I get a perpendicular angle to a unit vector? |
|
|
| Report Abuse |
|
|
| |
|