Answer the question
In order to leave comments, you need to log in
Vector does not exist in the current context
I wrote one of the scripts responsible for the movement and here is this:
Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMotor : BaseMotor
{
protected override void UpdateMotor()
{
MoveVector = InputDirection();
Move();
}
private Vector3 InputDirection()
{
Vector3 dir = Vector.zero;
dir.x = Input.GetAxis("Horizontal");
dir.z = Input.GetAxis("Vertical");
if (dir.magnitude > 1)
dir.Normalize();
return dir;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class BaseMotor : MonoBehaviour
{
protected CharacterController controller;
protected Transform thisTransform;
private float baseSpeed = 7.0f;
private float baseGravity = 25.0f;
public float Speed { get { return baseSpeed; } }
public float Gravity { get { return baseGravity; } }
public Vector3 MoveVector{set; get;}
protected abstract void UpdateMotor();
protected virtual void Start()
{
controller = gameObject.AddComponent<CharacterController>();
thisTransform = transform;
}
private void Update()
{
UpdateMotor();
}
protected virtual void Move()
{
controller.Move(MoveVector * Time.deltaTime);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question