Hi there,
I’m getting an error in Visual Studio when I try and add the two Vectors together (8:22 in the video) saying that it can’t add two Vector3 types.
This is my PlayerBaseState code
public abstract class PlayerBaseState : State
{
protected PlayerStateMachine stateMachine;
public PlayerBaseState(PlayerStateMachine stateMachine)
{
this.stateMachine = stateMachine;
}
protected void Move(Vector3 motion, float deltaTime)
{
stateMachine.CharacterController.Move((motion + stateMachine.ForceReceiver.Movement) * deltaTime);
}
}
And here’s my ForceReceiver code (the public method at the bottom I added to see if it worked instead of the shorthand Nathan used, but am getting the same error so that doesn’t seem to be the problem
public class ForceReceiver : MonoBehaviour
{
float verticalVelocity;
CharacterController characterController;
public Vector3 Movement => Vector3.up * verticalVelocity;
void Start()
{
characterController= GetComponent<CharacterController>();
}
void Update()
{
if (verticalVelocity < 0f && characterController.isGrounded)
{
verticalVelocity = Physics.gravity.y * Time.deltaTime;
}
else
{
verticalVelocity += Physics.gravity.y * Time.deltaTime;
}
}
public Vector3 ReturnVerticalMovement()
{
Vector3 movement = Vector3.up* verticalVelocity;
return movement;
}
}
Have spent an hour Googling it to no avail, any help would be appreciated! I’m sure it’s just something silly I’m overlooking…
Thanks in advance