Quantcast
Viewing all articles
Browse latest Browse all 107

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(); } void Update() { movement = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); } void FixedUpdate() { moveCharacter(movement); } void moveCharacter(Vector2 direction) { rb.AddForce(direction * speed); }

Viewing all articles
Browse latest Browse all 107

Trending Articles