Hello there. I’ve been working on an AI that should be able to move diagonally to a position without having the CharacterController to look at it. Meaning GameObject.transform.forward should not need to point in the direction of the desired location.
void MoveObjectReversed(AIOwnerGameObject owner, Vector3 toPosition)
{
Vector3 moveDirection = Vector3.zero;
// Direction to move.
// Owner - gameObject with some more features
// owner.movementSpeed - float
// IgnoreY(Vector3) - removes the y value
moveDirection = (IgnoreY(toPosition - owner.position)).normalized * owner.movementSpeed;
// Apply gravity
// owner.gravity - Vector3
moveDirection += owner.gravity;
// Move the controller
owner.controller.Move(moveDirection * Time.deltaTime);
}
Edit: I discovered the problem. It have nothing to do with this code. It’s working as intended ![]()