Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by k4z- · Apr 08, 2011 at 06:12 PM · pathcoordinatespathfollowingclimb

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges