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 ThiagoTejo · Dec 02, 2013 at 09:16 PM · rigidbodyraycasttranslatewallsshaking

How to make Rigidbody detect collisions but stop its movements

Hello guys, i'm making a third person controller using Translate for most of the movements, I use raycasts to detect both the lower and upper collisions, but detecting the collisions on x and z axis would demand a lot of raycasts, and i think that would be a bit heavy for the memory to handle. Then i decided to use a rigidbody, lock its Y position ( because i handle the Y position with the raycasts and all), and removed the gravity, because i already have a custom gravity with translate that respect the collisions because of the raycasts. because I wasn't using gravity, whenever i hitted a wall, the character keeped going the other way, but then i solved it by making: rigidbody.velocity = Vector3.zero; every frame, it stopped whatever velocity it gained and the charater stopped going through walls. But even so, having the rigidbody gave me some strange results, whenever i jump, the character starts shaking up and down ( while respecting the overall "route" of the jump ), and this is odd, because the Y position of the rigidbody is locked... And sometimes the character shakes with no apparent reaseon, I think its caused because the rigidbody sometimes gets a velocity in some axis, and even with my "rigidbody.velocity = Vector3.zero", i can't stop it completely. Well, what i want is to make my rigidbody works like a kinematic ( when i check the kinematic button, all shaking stops ) but still stop going throught walls... i know its kind of a paradox, but i guess you guys get it.

If its not possible, someone knows a simple way to detect collisions on x and z axis with raycasts? ( I think I could get the vector resulting from the x and z movement that my character does while walking, make a small raycast in this direction, and if it hits a wall, my character stops moving.. but i guess it wouldn't be enough... )

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

Answer by TheMidn1ght · Dec 03, 2013 at 12:39 AM

The problem is that you are using Translate to move your object which does not take into account anything physics related. This is probably why you were seeing odd things with the RigidBody. You will need to manually do the physics checks on your own with Raycast like you are thinking or you can convert all your movement code to utilizing the functionality given to you by the Physics engine in Unity by editing variables on your RigidBody and moving him with the velocity variable you have already tinkered with instead of just flat moving him with translate. Adding force and velocity and stuff like that will give you all the Physics collision based things for free.

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 ThiagoTejo · Dec 03, 2013 at 02:01 AM 0
Share

Thanks for your answer :) I'm using translate because I'm making a plataformer, and i need total control of the movements and the physics. I tried to do the same with rigidbodies once, but I couldn't get it to be so precise. Don't you a way to detect the walls with raycast and prevent the character from going through walls?

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

17 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

Related Questions

How to stop waypoints script in another script? 0 Answers

How to access component that the raycast hit 1 Answer

How to detect ground slope angles in 3d? 1 Answer

Boolean doesn't change at start position. 1 Answer

Trying to make a Projectile Rotate and Move Forward.. 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