CharacterController.Move called on inactive controller

In short, just can't move, can't move! !

In short, just can't move, can't move! !

In short, just can't move, can't move! !

A bunch of them on the Internet, .Move() .SimpleMove()

Net say something

Who can't call an Api, the problem is that it can't be moved, how to solve it?

Some people have to talk about the difference between the two APIs, let's look at the source code

All right. . . can not be seen

    /// <summary>
    ///   <para>Moves the character with speed.</para>
    /// </summary>
    /// <param name="speed"></param>
    public bool SimpleMove(Vector3 speed) => CharacterController.INTERNAL_CALL_SimpleMove(this, ref speed);

    [GeneratedByOldBindingsGenerator]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool INTERNAL_CALL_SimpleMove(CharacterController self, ref Vector3 speed);

    /// <summary>
    ///   <para>A more complex move function taking absolute movement deltas.</para>
    /// </summary>
    /// <param name="motion"></param>
    public CollisionFlags Move(Vector3 motion) => CharacterController.INTERNAL_CALL_Move(this, ref motion);

As evident from the above, Moves the character with speed(not delta time)?

Both SimpleMove() and Move() use the internal Internal method API, but simpleMove

Nope

no delta 吗

I don't know how SimpleMove does smooth movement without delta (according to the remarks above)

You love to use .SimpleMove() you use it yourself

But the problem is still, we can't move when we use CharacterController.Move()

 

After testing, it was found that the problem occurred in the function encapsulated by myself, or the BUG created by myself.

	//	HandleMovement();
	}

	private void LateUpdate()
	{
		HandleMovement();
		//ce测试过,可以移动 
		//GetComponent<CharacterController>().Move(new Vector3(0.1f, 0, 0) * Time.deltaTime);
	}

The final solution is to adjust HandleMovement(), which should have been a downward component of Move() before, resulting in abnormality and inability to move

Guess you like

Origin blog.csdn.net/avi9111/article/details/122776624