- Home /
Problem with the climbing of stairs ( character piloted by coordinates)
Hi there !
In a project I do, I've to pilot a character through 4D coordinates (3 axes and the time), but betweem 2 coordinates I want the character to collide, so I use a charactercollider and the Move function. It works fine excepting of the climbing of the stairs : Indeed the climbing is quicker than expected and the move continue after the climbing until the next coordinate re-position correctly the character. (Basically, the character climb the stairs, and fall from the roof instead of climbing slowler)
There is the update's code :
 // Update is called once per frame. Since the data could be a network stream we check the queue until the end of the scene void Update() { if (dataSet.Size() > 0 && Time.time > endPoint.w) // If there is a position recorded and that the current move is over { noDataLeft = false;
 
                    EnsurePosition();
     endPoint = dataSet.GetAndErasePeekVector4() + (Vector4)offset; // The new move's end point
     speed = Vector3.Distance(transform.position, endPoint) / (endPoint.w - Time.time);
     Vector3 lookTo = new Vector3(endPoint.x, transform.position.y, endPoint.z);
     transform.LookAt(lookTo); // Turn the fireworker toward their trajectory
 }
 if (Time.time <= endPoint.w) // While we have process the current move
 {
     Vector3 forward = transform.TransformDirection(Vector3.forward); // Convert the wolrd-related move to a charcter-related move
     forward *= speed; // Applying the average speed of the move
     applyGravity(ref forward);
     Debug.Log("Move through vector : " + forward.ToString(),transform);
     collisionFlags = characterController.Move(forward * Time.deltaTime); // Move the character controller forward
 }
 else if (dataSet.Size() == 0 && !noDataLeft) // The last move is over so we ensure the end position and that the character is grounded
 {
     noDataLeft = true; // We will wait until we receive new data or that the scene end
     EnsurePosition();
 }
 } 
There is the applyGravity procedure I used in the update function :
    // Applying the gravity of the world space if the character isn't on the ground
void applyGravity(ref Vector3 direction)
{
    if (collisionFlags != CollisionFlags.Below)
    {
        Debug.Log("Apply the gravity", transform);
        direction.y -= gravity;
    }
}
Could you help me please ? I think it's because the ditsance is computed including the height that the character climb, and in a certain way the speed computed from it is greater than what is needed.
Your answer
 
 
             Follow this Question
Related Questions
Mix up coordinates for greating new path? 0 Answers
Export camera path (first person controller) in x,y coordinates 2 Answers
Problem with moving through waypoint 0 Answers
Instantiate Objects Along a curved (circulair) Path 0 Answers
Object following the path 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                