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 francisliardet · Nov 08, 2011 at 05:40 AM · rigidbodycolliderfirst-person-controller

How to stop an object from moving rigidbody

In my game I have a FirstPersonControllerPrefab which is parent to a pickaxe which I have animated for both active and idle states. I want my pickaxe to collide with the rocks I am mining, but when it does, it pushes the rocks out of the way as I move forward.

My FPController has a rigidbody attached and my pickaxe has a kinematic rigidbody. There is a sphere collider at the tip of my pickaxe which is where the rocks are pushed from. If I make this collider a trigger, the rocks aren't pushed but my pickaxe goes throuh the surface which is not what I want.

Is there a way I can have the pickaxe collide with another rigidbody whilst being unable to move?

Any help would be greatly appreciated,

Francis.

PS: I have tried freezing the movement of the rocks from the rigidbody but this just means that the pickaxe goes through the rock even if it isn't a trigger. I have also tried setting the mass of the rocks to 999999 but this has no effect.

alt text

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
Best Answer

Answer by syclamoth · Nov 08, 2011 at 05:53 AM

There are a couple of ways, here- you can use Layer-based collision to stop the rocks from colliding with anything except the ground and the pickaxe, and you could set up the collider on the pick so that it acts like a trigger whenever you aren't swinging it.

Comment
Add comment · Show 5 · 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 francisliardet · Nov 08, 2011 at 06:31 AM 0
Share

I had a go with both of these methods but neither worked. The problem is that because the pickaxe is parented to the FPController, when the player moves, the pickaxe does the exact same thing. This means that even if I do have the rock set to only collide with ground and pickaxe, moving forward will still push the pickaxe into the rock and move it. The collider at the end of the pickaxe is the only thing affecting the rock, if I turn my back to the rock and try to push without the contact of pickaxe to rock, I collide, but do not move it. If I remove the pickaxe's collider completely, it passes through and the controller collides with the rock without moving.

avatar image syclamoth · Nov 08, 2011 at 06:43 AM 0
Share

Let me get this straight, you want to have the rock act as a rigidbody when you hit it with the pick, but act like a static collider for your character?

avatar image francisliardet · Nov 08, 2011 at 06:47 AM 0
Share

$$anonymous$$ore or less yes... Everything is fine with the setup I have at the moment EXCEPT when the pickaxe's collider touches the rock it pushes it out of the way ins$$anonymous$$d of just hitting it like a pickaxe in real life would do. Sorry if i'm confusing you, I've only just started making games with unity

avatar image syclamoth · Nov 08, 2011 at 07:00 AM 0
Share

No, no that's fine. Well, for this I'd just have the pickaxes' collider set to

 isTrigger = true;

while it's not actually swinging, that way it won't push things out of the way when you don't want it to.

avatar image francisliardet · Nov 08, 2011 at 07:08 AM 0
Share

It's a good idea but it still leaves the problem of the pickaxe going through the rock when the player isn't picking which isn't very realistic. What I have done is ins$$anonymous$$d placed a virtual copy of the pickaxe on it's own layer which removes this problem, and i'll make an invisible trigger collider where the pick would of been to handle the collisions :) http://answers.unity3d.com/questions/17841/always-render-a-object-on-top-of-another.html

Thanks for all your help though!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

How to make colliders without using any of the inbuilt physics 1 Answer

Player walks through everthing 0 Answers

Access other collider without use of Trigger collider. 1 Answer

Sprites doens't collide properly or bypass each other 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