Character Controls into another Model w/ Humanoid?
I apologize in advance for butchering my question, but what I'm pretty much trying to do is 'transfer', or replicate, default character controls into another model that has a humanoid (meaning 'W' will move the model forward depending on the direction the camera is facing, 'D' will move the model backwards, etc.)
There was a Wiki article explaining how to create and manipulate player movement that I found useful and helped provide a starting point for me. The article can be found here.
What I have so far works pretty well, but it's not what I want. Here's the code I've taken from the Wiki, and edited so it works alongside what I have at the moment;
03 | local userInputService = game:GetService( "UserInputService" ) |
04 | local runService = game:GetService( "RunService" ) |
05 | local player = game.Players.LocalPlayer |
06 | local moveVector = Vector 3. new( 0 , 0 , 0 ) |
08 | userInputService.InputBegan:connect( function (inputObject) |
10 | local poke = workspace:FindFirstChild(player.Name.. "'s Pokemon" ) |
13 | if inputObject.KeyCode = = Enum.KeyCode.A then |
14 | moveVector = moveVector + Vector 3. new( 1 , 0 , 0 ) |
16 | if inputObject.KeyCode = = Enum.KeyCode.D then |
17 | moveVector = moveVector + Vector 3. new(- 1 , 0 , 0 ) |
19 | if inputObject.KeyCode = = Enum.KeyCode.Space then |
20 | poke.Humanoid.Jump = true |
25 | userInputService.InputEnded:connect( function (inputObject) |
27 | local poke = workspace:FindFirstChild(player.Name.. "'s Pokemon" ) |
30 | if inputObject.KeyCode = = Enum.KeyCode.A then |
31 | moveVector = moveVector + Vector 3. new(- 1 , 0 , 0 ) |
33 | if inputObject.KeyCode = = Enum.KeyCode.D then |
34 | moveVector = moveVector + Vector 3. new( 1 , 0 , 0 ) |
39 | runService.RenderStepped:connect( function () |
41 | local poke = workspace:FindFirstChild(player.Name.. "'s Pokemon" ) |
44 | poke.Humanoid:Move(moveVector) |
Here's a GIF showing how the code works in-game so far; Link
As you can tell within the script and GIF, the controls don't function exactly like the default controls- which is where I need some assistance. Upon pressing A or D, the model will only move relative to the world space, not the model's position or the direction of the camera.
I've worked with Lua for a while now, but this is certainly one of the things that continue to puzzle me no matter how hard I try to attempt it.
What would I need to do in order to accomplish the task I'm trying to complete? Or is there a much easier solution around this problem?
I don't necessarily need a definite answer, but I'd appreciate any general tips that could lead me to the correct path. Thanks!