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 seb-lopez · Mar 28, 2015 at 11:10 AM · charactercontrollerjumpbounce

Sonic trampoline style with character controller(old one)

Any one knows how to do a trampoline (sonic style)with a character controller because i don't see any tutorials about it. i don't expect someone making me a script( if someone do a Great thanks) but i would like some directions.

Comment
Add comment · Show 1
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 MakakWasTaken · Mar 28, 2015 at 12:32 PM 0
Share

Could you specify what a sonic style trampoline is? If it is a trampoline can't you make a Physics material for the trampoline with low friction?

1 Reply

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

Answer by ExplodingCookie · Mar 28, 2015 at 12:55 PM

Character Controllers move when the Move() function is called and a Vector3 is provided. This Vector3 can be calculated in a number of ways.

 //How fast we move
 var moveSpeed = 6.0;
 
 //Gravity strength
 var theGravity = 20.0
 
 //How fast up or down we are going.
 private var verticalSpeed = 0.0;
 
 var controller : CharacterController;
 
 //This is the vector the Move() function uses.
 var finalMovement : Vector3;
 
 function MovementUpdate () {
 
     //Define the input we can get from a player
     var vertical : String = "Vertical";
     var horizontal : String = "Horizontal";
 
     //Next we calculate the horizontal moment from the input values
     var zxMovement = Vector3(horizontal, 0, vertical) * moveSpeed * Time.deltaTime;
 
     //After this, we calculate gravity.
     verticalSpeed -= theGravity * Time.deltaTime;
 
     //But if the controller is on the ground, we set the vertical speed to zero to prevent dropping off the edge.
     if(controller.isGrounded) {
         verticalSpeed == 0;
     }
 
     //Now we calculate the final vector
     finalMovement = zxMovement + Vector3(0, verticalSpeed, 0);
 }
 
 function Update () {
     MovementUpdate();
     controller.Move(finalMovement);
 }

After this, a spring simply sets the vertical speed to something high.

Add this after the Update in the last script.

 function SuperJump (strength : float) {
     verticalSpeed = strength;
 }

Then add a script to the object you want to do the launching that calls the SuperJump() and provides a strength.

 var strength = 25.0;
 
 function OnTriggerEnter(col : Collider) {
     //Make sure to name the controller script "PlayerController" or else this won't work!
     if(col.GetComponent(PlayerController)) {
         col.SendMessage("SuperJump", strength);
     }
 }

This is just the basics. Hopefully I didn't typo something. xD. Anyway. Hope this helps!

Comment
Add comment · Show 1 · 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 seb-lopez · Mar 29, 2015 at 11:53 PM 0
Share

euh i forgot to mention but im using the unity character controller with their built in script =( and i don´t know what to reference in the fpscontrollerscript.

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

22 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

Related Questions

Jumping not always work 2 Answers

I aren't able to jump. I find no mistake in the script 1 Answer

How to jump multiple times to mid air? 3 Answers

Trouble with spring platform 0 Answers

I cant make my Character jump. 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