Simple 3d controls
I am pretty new to game design and coding. And have been watching tutorial after tutorial on movement controls but I still can't figure out how to write a simple C# script 3rd person 3D controls. I was thinking of a move camera with mouse then move with character with D-pad. That works well when walking. but with the Z axis added I'm not sure what controls would be best...and simplest.
I want to use the controls to simulate swimming underwater. I've worked out the Rigid Body component to give the drag effect I want. But controls...
This is the closest I found but, again, it's only 2D. Thank you in advance!
Author: Press Start - YouTuber
public float speed = 2.5f;
public Rigidbody rb;
public Vector2 movement;
void Start()
{
rb = this.GetComponent<Rigidbody>();
}
void Update()
{
movement = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
}
void FixedUpdate()
{
moveCharacter(movement);
}
void moveCharacter(Vector2 direction)
{
rb.AddForce(direction * speed);
}
Your answer
Follow this Question
Related Questions
Swimming in a sinusoidal fashion, positive cycle out of water and negative within. Am I close? 0 Answers
How would i clamp X and Z without clamping Y? 1 Answer
How can I make character accelerate and deccelerate using GetAxis? 0 Answers
CAn soem one give me Sphere script to move in third person 0 Answers
Controls won't work in executable file 0 Answers