|
| 23 May 2013 02:53 PM |
I can do the scripting for WaSD/Arrows, but how would I move an object in Workspace called "Part".
BEFORE YOU SAY CFRAME : While the object is moving, it was to be able to interact with laws of physics and be collide-able with other objects, CFrame ignores both. The part has to interact with physics and collide with other objects.
So what would be your way/idea of how to do so? |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 May 2013 03:06 PM |
Ah. um, next question how would you make it move in direct the part is "looking"?
here's my script so far
local part = game.Workspace.Part local pos = Instance.new("BodyVelocity")
function onKeyDown(key) if key:lower() == "w" then pos.Parent = part moving = true while moving== true do pos.velocity = blank, no idea what would go here. wait(.001) end
mouse.KeyDown:connect(onKeyDown) |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 03:10 PM |
Well what exactly are you trying to script? Like; will you be first-person viewing the object? |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 03:12 PM |
Use bodyposition and set its position to the lookvector of the part * 2
( ._.)|) ( D:) |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 03:17 PM |
| Or you can use bodyvelocity, which I like using a lot more and find it easier. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 03:21 PM |
@KanataIzumi7, not necessary I'll most be viewing it in 3rd person to make sure it moves. And I'm trying to make a part in workspace move when you press W, but the part has to interact with collision.
@sloomingbla So changing it to BodyPosition I made this :
pos.position = pos.position.lookVector * 2
I'm not very good with BodyPosition, so I really don't understand the lookVector part of it... So I know the snippet above isn't going to work. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 03:23 PM |
So just move the brick forward in the direction it's facing, or in the direction the player is moving forward in?
If the first, then using what the others mentioned would work? |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 03:32 PM |
| the first, but my only problem is.. I can't figure out the lookVector for BodyPosition and BodyVelocitys.. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 03:44 PM |
| CFrame.lookVector returns the direction it's look at, so you could use that. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 03:59 PM |
^ that
do pos = part.CFrame.lookVector * 2
( ._.)|) ( D:) |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 04:01 PM |
bodyvelocity.velocity = part.CFrame.unit*(a certain number; the speed)
|
|
|
| Report Abuse |
|
|
|
| 23 May 2013 04:17 PM |
@TheAwesomenessDude
function onKeyDown(key) if key:lower() == "w" then pos.Parent = game.Workspace.Part moving = true while moving == true do local part = game.Workspace.Part direction = game.Workspace.Part.CFrame.lookVector * 9999 -- I think I need this.. pos.velocity = part.CFrame.unit*(direction) wait(.001) end end
16:14:57.072 - Unit is not a valid member
|
|
|
| Report Abuse |
|
|
|
| 23 May 2013 04:18 PM |
velocity is hard to work with, atleast for me.
trust me, use bodyposition :3
or just use moveto on a humanoid?
( ._.)|) ( D:) |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 04:28 PM |
MoveTo() is toooo glitchy.
function onKeyDown(key) if key:lower() == "w" then local part = game.Workspace.Part pos.Parent = game.Workspace.Part -- Line 41 driving = true while driving == true do pos = part.CFrame.lookVector * 2 wait(.001) end end
Why? 16:26:39.046 - Parent cannot be assigned to 16:26:39.046 - Script "Players.Player1.Backpack.test.LocalScript", Line 41 16:26:39.047 - stack end
|
|
|
| Report Abuse |
|
|
| |
|
|
| 23 May 2013 05:00 PM |
It just says the line #... no error like "eof", etc?
Disregard females, acquire currency. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 05:15 PM |
oh, add an extra end. Sorry I didn't copy it..
|
|
|
| Report Abuse |
|
|
|
| 23 May 2013 05:46 PM |
I don't think the ends are your issue, I was just wondering what random error the output gave.
Disregard females, acquire currency. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:04 PM |
function onKeyDown(key) if key:lower() == "w" then pos.Parent = game.Workspace.Part --stay.Parent = game.Workspace.Part driving = true while driving == true do local part = game.Workspace.Part direction = game.Workspace.Part.CFrame.lookVector * 9999 pos = part.CFrame.lookVector * 2 wait(.001) end end end
run it, bam you get the output I posted above. |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:04 PM |
Literally just the line number? o_O
I don't think you'll get much help without some kind of output.. I hate the output sometimes D:
Disregard females, acquire currency. |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 May 2013 06:12 PM |
ugh...
FULL SCRIPT :
local pos = Instance.new("BodyPosition") local hopper = script.Parent local mouse = plr:GetMouse() local driving = false
function onKeyDown(key) if key:lower() == "w" then local part = game.Workspace.Part pos.Parent = game.Workspace.Part -- Line 41 driving = true while driving == true do pos = part.CFrame.lookVector * 2 wait(.001) end end
hopper.Selected:connect(function() mouse.KeyDown:connect(onKeyDown) mouse.KeyUp:connect(onKeyUp) end)
plr.Character.Humanoid.Changed:connect(function() plr.Character.Humanoid.Jump = false plr.Character.Humanoid.Sit = true end)
Output.. 16:26:39.046 - Parent cannot be assigned to 16:26:39.046 - Script "Players.Player1.Backpack.test.LocalScript", Line 41 16:26:39.047 - stack end |
|
|
| Report Abuse |
|
|
|
| 23 May 2013 06:19 PM |
Try this
local pos = Instance.new("BodyPosition") local hopper = script.Parent local mouse = plr:GetMouse() local driving = false
function onKeyDown(key) if key:lower() == "w" then local part = game.Workspace.Part pos.Parent = part -- Line 41 driving = true while driving == true do pos = part.CFrame.lookVector * 2 wait(.001) end end
Disregard females, acquire currency. |
|
|
| Report Abuse |
|
|
| |
|