Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Oct 23, 2015 at 10:29 PM by David-Selkirk for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by David-Selkirk · Aug 29, 2015 at 04:30 PM · rotationphysicsvector3skateboard

Skateboarder behaving incorrectly on half-pipe

I'm currently creating a skateboarding game and have hit a bit of a problem with half-pipes. At the moment my character simply moves at a constant forward velocity and adjusts it's orientation based on a downwards raycast (to hug the terrain).

The problem arises when my character goes up a half-pipe. What I want to happen, ala Tony Hawks, is that the character simply continues in it's current motion straight upwards and lands back down on the halfpipe. However, my character is retaining some forward momentum and travels up and over the pipe instead.

My initial solution was to place a trigger at the top op the pipe that adjusts the characters local orientation so they are perpendicular to the imaginary wall of the halfpipe. Here's the code (angleX is set to 270)

 Vector3 newLocalAngle = new Vector3(angleX, coll.gameObject.transform.localRotation.eulerAngles.y,          coll.gameObject.transform.localRotation.eulerAngles.z);
 
 Vector3 oldLocalAngle = coll.gameObject.transform.localRotation.eulerAngles;
 coll.gameObject.transform.localRotation = Quaternion.Euler(newLocalAngle);

I then get rid of any local y velocity on the character, to remove any motion forwards or backwards.

     Vector3 newVel = coll.gameObject.transform.InverseTransformDirection(coll.gameObject.GetComponent<Rigidbody>().velocity);
  newVel.y = 0;
     
     coll.gameObject.GetComponent<Rigidbody>().velocity = coll.gameObject.transform.TransformDirection(newVel);
    

This unfortunately is snapping the player to face straight up in the world y direction, stopping any sideways motion (relative to the halfpipe).

Can anyone suggest a fix for this code, or a better way to approach the problem?

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

1 Reply

  • Sort: 
avatar image
0

Answer by KlausJoensuu · Aug 29, 2015 at 04:57 PM

I'm not sure what you are talking about but i would check the physics settings. Edit -> Project settings -> Physics. You can always just create you're own physics system for scratch too if it is needed. If i was to build a game like that i would start by making a custom physics manager where i can detect if in "Half-pipe". Hope that will help in someway...

Comment
Add comment · Share
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

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Follow a curve using physics or transform manipulation 2 Answers

How to get rotation relative to the ground normal? 0 Answers

Turning a rigidbody that's in motion 2 Answers

How do I determine which Euler Axis of an object will change when the object is rotated? 1 Answer

Game Object rotation sometimes doesn't match defined quaternion 0 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