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 L5D7 · Feb 29, 2012 at 05:01 PM · transformjumpingfirst-person-controllerlaunch

Transforming while jumping launches controller into space

So I'm working on a game that transforms the First Person Controller whenever they come into contact with an object. The Controller is transformed 1 unit up on the y axis. While the controller will transform perfectly if it walking and it hits the object, if the character hits the object while jumping then the transform seems to add to the jumping velocity and launches the controller super high in the air. Has anyone else noticed this and/or know of a solution to it?

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

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Berenger · Feb 29, 2012 at 05:21 PM

The jump with the character controller is performed with a velocity and the function move. When you hit that cube while jumping, the velocity is unchanged, so it keep travelling the distance it's supposed to, plus the +1 unit you gave it. I'm not sure that accuracy (+1 unit) is going well with physic, you might have to choose between them.

Comment
Add comment · Show 3 · 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
avatar image L5D7 · Feb 29, 2012 at 05:41 PM 0
Share

Thank you for replying, is there a way I can disable the jumping mid-script? So that once it collides with the cube while jumping, the jumping stops and the +1 takes over?

avatar image Berenger · Feb 29, 2012 at 06:05 PM 0
Share

Character$$anonymous$$otor have a SetVelocity function. call SetVelocity(Vector.zero). Be carefull, Sned$$anonymous$$essage("OnExternalVelocity") will throw an error if you don't have the function, as well add Send$$anonymous$$essageOptions.DontRequireReceiver to it.

avatar image L5D7 · Feb 29, 2012 at 09:39 PM 0
Share

Thanks for the advice but that didn't quite work. It changes the velocity but the velocity is compiled every update so it doesnt matter what you change it to. I was able to locate where the controller is being launched upwards, it around line 402 in Character$$anonymous$$otor.js

velocity.y = movement.velocity.y - movement.gravity * Time.deltaTime;

movement.velocity.y is the reference that is the enormous jump (the value was around 40 at it's highest). To fix it I put a limit on the velocity right after this line so that if the velocity is over 6, then limit it to 6 (6 was the value for an average jump).

velocity.y = movement.velocity.y - movement.gravity * Time.deltaTime; if(velocity.y > 6) velocity.y=6;

This works and the Controller now jumps and translates together without high-five-ing the moon. Thank you again for your help.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Smoother Camera Movement without making camera child of the player? 0 Answers

I am trying to make a first person controller but I can't make ta player jump. Can I solve this problem without importing assets? 0 Answers

Changing the parent transform of the First Person Controller 1 Answer

how can i change the x position while jumping on air using c#? 1 Answer

Freezing Transforms 2 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