Hi there,
I’m currently make a third person multiplayer game in unity, and i’m kind of struggling to get nice third person movement
and i have tried everything but just didn’t fell right, or work right. So if anyone could maybe help me with some idea’s of what i could do or check out. And also this doesn’t really feel right for me only because i’m also trying to and in some animations.
And also i have tried this piece of code but can’t seem to get it working because it gives me a error saying, Vector2 does not contain a definition for ‘GetKey’.
Here is the code:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float walkSpeed = 2;
public float runSpeed = 6;
Animator animator;
void Start() {
animator = GetComponent();
}
void Update() {
Vector2 input = new Vector2(Input.GetAxisRaw(“Horizontal”), Input.GetAxisRaw( “Vertical”));
Vector2 inputDir = input.normalized;
if(inputDir != Vector2.zero){
transform.eulerAngles = Vector3.up * Mathf.Atan2(inputDir.x, inputDir.y) * Mathf.Rad2Deg;
}
bool running = input.GetKey(KeyCode.LeftShift);
float speed = ((running) ? runSpeed : walkSpeed) * *inputDir.magnitude;
transform.Translate(transform.forward * speed * Time.deltaTime, Space.World);
float animationSpeedPercent = ((running) ? 1 : .5) * inputDir.magnitude;
animator.SetFloat(“SpeedPercent”, animationSpeedPercent);
}
}