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 leke · Jan 04, 2014 at 02:42 AM · rigidbodycharacterjumpcube

How do I make my character jump over a cube with rigid body moving towards it

pls can anyone help! I'm new to unity and I'm trying to make my character jump over a cube moving towards him but the rigidbody attached to the cube makes it impossible to jump over. Both the character and cube have rigid bodies attached to them. Also when the cube is in motion (moving towards the character) it allows the character pass through it instead of repeling the player back on collision. Pls any advice wud b really appreciated. Thanks in advance. This is the script I used to move the cube towards him.

    #pragma strict
     var speed:float = 17.0f; // move speed
     
     function Start () {
      
     }
      
     function Update () {
     transform.position = Vector3.MoveTowards(transform.position, Vector3(-0.0001,3.67707,7.64789), speed*Time.deltaTime);
      
     }
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
1
Best Answer

Answer by HappyMoo · Jan 04, 2014 at 02:46 AM

If you move rigidBodies by changing their positions, the physics system doesn't work.

move the rigidBodies in FixedUpdate by applying forces to them or setting the velocity.

 function FixedUpdate()
 {
   rigidbody.velocity = Vector3.forward*speed;
 }
Comment
Add comment · Show 7 · 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 clunk47 · Jan 04, 2014 at 03:08 AM 1
Share

I'd like to add on to this answer, have a look at rigidbody.$$anonymous$$ovePosition.

avatar image HappyMoo · Jan 04, 2014 at 03:14 AM 1
Share

Ah, nice... that method will come in handy some day :D

avatar image leke · Jan 04, 2014 at 03:27 AM 0
Share

Thanks so much for the replies...I really appreciate it. But the cube still passes through the character ins$$anonymous$$d of repeling him backwards. Pls any advice on how to solve dat? Thanks in advance once again

avatar image HappyMoo leke · Jan 04, 2014 at 03:37 AM 1
Share

Did you also add Colliders? This gives a good overview over Unity's Physics: http://unity3d.com/learn/tutorials/modules/beginner/physics

avatar image clunk47 · Jan 04, 2014 at 03:39 AM 0
Share

@Happy$$anonymous$$oo +1, good reference.

avatar image leke · Jan 04, 2014 at 03:51 AM 0
Share

@Happy$$anonymous$$oo yes I did but I'm not too sure of the type of collider I'm supposed to add to my game character, he already has a rigidbody, character controller and an animator, but my cube has a box collider and a rigidbody...pls which type of collider can I add to my character? Thanks in advance

Show more comments

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

20 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How can I create a "round arc" physics based jump? 2 Answers

Translation of an object 2 Answers

Make jump high as long as you press? 0 Answers

hit.normal cube 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