![]() ![]() this means that this can be shortened too. and you can multiply a Vector3 by a number.Ĭontroller.SimpleMove(MovementDirection * MoveSpeed) MovementDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) -1 when arrow left, and +1 when arrow right. Axis Horizontal/Vertical are mapped to the arrow keys and wasd. if (Input.GetKeyUp(Ke圜ode.D)) MovementSpeed.x -= 2 if (Input.GetKeyUp(Ke圜ode.S)) MovementSpeed.z += 2 ![]() if (Input.GetKeyUp(Ke圜ode.A)) MovementSpeed.x += 2 if (Input.GetKeyUp(Ke圜ode.W)) MovementSpeed.z -= 2 if (Input.GetKeyDown(Ke圜ode.D)) MovementSpeed.x += 2 if (Input.GetKeyDown(Ke圜ode.S)) MovementSpeed.z -= 2 if (Input.GetKeyDown(Ke圜ode.A)) MovementSpeed.x -= 2 if (Input.GetKeyDown(Ke圜ode.W)) MovementSpeed.z += 2 if (Input.GetKeyUp(Ke圜ode.D)) MovementSpeed.x -= 4 if (Input.GetKeyUp(Ke圜ode.S)) MovementSpeed.z += 4 if (Input.GetKeyUp(Ke圜ode.A)) MovementSpeed.x += 4 if (Input.GetKeyUp(Ke圜ode.W)) MovementSpeed.z -= 4 if (Input.GetKeyDown(Ke圜ode.D)) MovementSpeed.x += 4 if (Input.GetKeyDown(Ke圜ode.S)) MovementSpeed.z -= 4 if (Input.GetKeyDown(Ke圜ode.A)) MovementSpeed.x -= 4 if (Input.GetKeyDown(Ke圜ode.W)) MovementSpeed.z += 4 holding leftshift, move speed will be 4. (?) you kind of combined movement direction and speed. I can see why you are stuck, there are some odd things like GetKeyDown and a movespeed that increases. ![]() I posted this in help room as well and since I posted it there I updated my move script to the new input system but I'm still stuck and could really do with some help with the actual movement. The code currently uses the old input system, and I'm hoping to update it to the new system once this movement script is complete, as all I have to do is change the input methods. Public class Movement : MonoBehaviour As shown in the code, I'm using a character controller instead of a rigidbody and missing an up/down look script. Using System.Collections using using UnityEngine I've been working on a game for nearly a week and, being a near-complete noob with lots of programming experience in anything but c#, I'm stuck while making a movement script. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |