Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 chainylol · Jul 09, 2017 at 09:54 PM · rigidbodyprogrammingforcerigidbody.addforcejumping object

Basic Jump Pad help

Hey everyone, I need some help with creating a basic jump pad. My idea is that when the player collides with a specific gameObject (the jump pad), it will add a force to the player on its Y-axis, making the player "jump". I've tried using rigidbody.AddForce, but it does not seem to work. If i untick "Is Trigger" on both the player and the jump pad, the collision register, but no force is added.

Any help appreciated!

Comment
Add comment · Show 7
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 Littellittel · Jul 09, 2017 at 09:57 PM 0
Share

Hi, some more details would be nice.

Show your code, what exactly did happen with rigidbody.AddForce?

avatar image chainylol Littellittel · Jul 09, 2017 at 10:00 PM 0
Share

JS:

var speed:int = 5;

function OnControllerColliderHit(hit:ControllerColliderHit) {

if(hit.gameObject.tag== "Player") { Debug.Log("Ok"); hit.rigidbody.AddForce(Vector3.up * speed); } }

On collision, nothing happens to the player. No force is added no matter how high i set the value. I'm thinking it has to do with the type of collision i used, not sure though.

avatar image Littellittel chainylol · Jul 09, 2017 at 10:06 PM 0
Share

ok,

what exactly did happen while using this code?

do you have any console output?

Since I dont know you project I cant say anything perticular but you could check if hit.rigidbody is returning null.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by Jwizard93 · Jul 09, 2017 at 10:27 PM

So I don't use unityScript and I didn't use a player controller. Just a standard collision between two box colliders. I didn't see anything happening until I raised the value of "speed" 500 was good for me. Heres the code for jumpPad:

 public class jumpPad : MonoBehaviour {
 
     public int speed;
 
     void OnCollisionEnter(Collision other)
     {
         if (other.gameObject.CompareTag("Player"))
         {
             other.gameObject.GetComponent<Rigidbody>
                     ().AddForce(Vector3.up*speed);
         }
     }
 }
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 chainylol · Jul 09, 2017 at 10:38 PM 0
Share

thank you so much!

avatar image shidonflor · Jun 20, 2020 at 10:10 AM 0
Share

Didn't work for me :(

avatar image N-8-D-e-v shidonflor · Aug 21, 2020 at 07:48 PM 0
Share

replace the () with the name of your rigidbody

avatar image
0

Answer by AntiBeta · Feb 07 at 10:58 PM

If your jumping script also use AddForce() the jump pad script and the jump script can be overlapped thus: you need to reset your characters RBs velocity before jump pads code runs. example is under below

     other.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
     other.gameObject.GetComponent<Rigidbody>().AddForce(Vector3.up*bounce, ForceMode2D.Impulse);

also; if u want to save your horizontal velocity you can use like this:

    other.gameObject.GetComponent<Rigidbody>().velocity = 
    new Vector3(other.gameObject.GetComponent<Rigidbody>().velocity.x,0,0);

Do not forget if your game is 2D you need to change Rigidbodys => Rigidbody2D and Vector3 => Vector2

good luck :)

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

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

92 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

add force to object that has 2 different rigid bodies 0 Answers

rigidbody problem 1 Answer

Rigidbody velocity has got different direction than VelocityChange force vector 1 Answer

How would you code a Wind script? 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