|
| 08 Dec 2014 06:17 PM |
| Okay im working on a fire ball it works fine I press r and it spawns in the middle of the map.thats the problem how would I make it so when you spawn the fireball it follows your mouse?im not sure how to do that is anyone willing to teach me? |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Dec 2014 06:25 PM |
| How would it follow your mouse? |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2014 06:27 PM |
| correct,how would I make it so when it spawns it follows your mouse |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2014 06:28 PM |
| I mean how exactly does it follow it? Does it move to wherever the mouse is (on a surface), does it float a specific distance away from the player but in the direction of the mouse, does it follow your mouse on your screen...? |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2014 06:28 PM |
| Close your eyes and imagine your game: describe to me exactly what you want it to look like. |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2014 06:31 PM |
| okay I spawn the fire ball it spwans and then it heads it goes the direction the mouse was pointed at no it dosent move to the mouse it goes to the direction the mouse was pointed at |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2014 06:35 PM |
Whatever game you're working on, it sounds fun!
What you wanna do is this: ========================== 1. Add a 'BodyVelocity' to the fireball. This makes it move. 2. Make the Velocity of it the mouse direction. ==========================
In this script, I'm making 'fireball' the fireball you just spawned. I'm making 'character' the character of the player. I'm also making 'mouse' the player's mouse (you used KeyDown on it): ========================== local bv = Instance.new("BodyVelocity") bv.Parent = fireball bv.Name = "Velocity" bv.velocity = (character.Torso.Position - mouse.Hit.p).unit*50 ========================== Remember the variables I used, and substitute your variables in: fireball - the fireball character - the player's character mouse - the mouse |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2014 06:39 PM |
Player = script.Parent.Parent mouse = Player:GetMouse()
function onKeyDown(key) key = key:lower() if key == "r" then local brick = Instance.new("Part", game.Workspace) brick.Name = "NewBrick" brick.Size = Vector3.new(3,3,3) brick.Shape = ("Ball") Instance.new('Fire',brick) brick.Transparency = 0.5 end end
mouse.KeyDown:connect(onKeyDown) |
|
|
| Report Abuse |
|
|
|
| 08 Dec 2014 06:45 PM |
Player = script.Parent.Parent mouse = Player:GetMouse()
function onKeyDown(key) key = key:lower() if key == "r" then local brick = Instance.new("Part", game.Workspace) brick.Name = "NewBrick" brick.Size = Vector3.new(3,3,3) brick.Shape = ("Ball") brick.CanCollide = false brick.Position = Player.Character.Torso.Position + Player.Character.Torso.CFrame.lookVector*5 brick.TopSurface = "Smooth" brick.BottomSurface = "Smooth" Instance.new('Fire',brick) brick.Transparency = 0.5 local bv = Instance.new("BodyVelocity") bv.Parent = brick bv.velocity = (mouse.Hit.p - Player.Character.Torso.Position).unit*50 end end
mouse.KeyDown:connect(onKeyDown) |
|
|
| Report Abuse |
|
|