Hi! Really starting Newbie here
I want to move my character ONLY forward when W key is pressed
so I made this script to character only go forward
anyone can kindly tell me why this script having error?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public Animator anim;
public float speed = 12f;
void Update()
{
anim.SetFloat("Verti", Input.GetAxis("Vertical"));
anim.SetFloat("Hori", Input.GetAxis("Horizontal"));
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.forward * z;
if (move <= 0)
{
move = 0;
}
else {
controller.Move(move * speed * Time.deltaTime);
}
}
}