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
1
Question by stingman · Mar 03, 2012 at 08:28 PM · velocityjumpforcecharacter controller

creating a jump pad for a character controller

My character is being controlled with a character controller. I'm trying to do the following: "when my character is standing on top of a jump platform then he has the ability to jump significantly higher than when hes not standing on it."

Here is my setup:

I have a game object (jump pad) with a box collider and trigger checked. I referenced the 3d platformer tutorial for some general ideas. I apply this script to the game object (jump pad):

var jumpHeight = 20.0;

function OnTriggerEnter (col : Collider) { var controller : PlatformerController = col.GetComponent(PlatformerController);

 if (controller != null)
 {
     if (audio) 
     {
         audio.Play();
     }

     controller.SuperJump(jumpHeight);
 }
 

}

// Auto setup the script and associated trigger.

function Reset () { if (collider == null)

     gameObject.AddComponent(BoxCollider);
 
 collider.isTrigger = true;

}

@script RequireComponent(BoxCollider)

I'm using the platformer controller script from the 2d Platformer Tutorial. the super jump function was missing from this script so i copied it over from the third person controller script. Here is the code:

function SuperJump (height : float) { verticalSpeed = CalculateJumpVerticalSpeed (height);

 collisionFlags = CollisionFlags.None;
 
 SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);

}

function SuperJump (height : float, jumpVelocity : Vector3) { verticalSpeed = CalculateJumpVerticalSpeed (height);

 inAirVelocity = jumpVelocity;
 
 collisionFlags = CollisionFlags.None;
 
 SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);

}

I'm not getting any errors when compiling and I can run the game but when I jump on the "jump platform" he jumps at normal height... not the specified increased height. I am getting several warnings relating to the above script:

WARNING: Unused local variable 'verticalSpeed'. (BCW0003)

WARNING: Unused local variable 'collisionFlags'. (BCW0003)

WARNING: Unused local variable 'inAirVelocity'. (BCW0003)

I'm not sure what the issue is and am hoping someone can help me out here. If there is another way to go about this I'm open to trying other things as well. Appreciate any help.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Louard · Apr 07, 2012 at 06:06 PM

If you are using the Character Motor there's a function for that. After three days of trying to roll my own solution based on a few posts to the forum and the Answers I found this function and VOILA! Exactly what I wanted to do! Perfect for jump pads and knock back! Here's what my jump pad script now looks like.. MUCH simpler! The SetVelocity() function in the Character Motor accepts the velocity as an initial force and the motor takes care of the rest.

 #pragma strict
 
 
 var moveVelocity : Vector3 = Vector3.zero;
 
 private var thePlayerMotor : CharacterMotor;
 
 function Start(){
     thePlayerMotor = GetComponent(CharacterMotor);
 }
 
 function OnTriggerEnter(WhatHitMe : Collider){
     if (WhatHitMe.gameObject.tag == "JumpPad"){
         moveVelocity = Vector3(0,50,0);
         thePlayerMotor.SetVelocity(moveVelocity);
     }
 }
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
avatar image
0

Answer by stingman · Mar 03, 2012 at 11:08 PM

Got it working. Took a completely different route based off this question/answer.

http://answers.unity3d.com/questions/172274/charactercontrollermove-jump-not-working.html

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 zimmer550 · Jul 23, 2016 at 09:44 PM 0
Share

Hi! Can you tell me how you got a working jump pad?

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

6 People are following this question.

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

Related Questions

Convert Force into Velocity for 2D Player Jump 0 Answers

How to make character controller jump? 1 Answer

ForceMode.Impulse Doesnt always fire. 2 Answers

Inconsistent Jump height 3d 3 Answers

how can I make a character fly when holding down the jump button? 1 Answer


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