• 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 MarcusDLB · Aug 28, 2013 at 02:42 AM · collisionmovementpickupclipping

How to get correct collision when picking up objects and moving them at high speeds near walls?

I made a script that I attached to the First person controller that allows me to pick up objects, rotate and thrown them similar to amnesia the dark decent.Collisions work to an extent but the problem is, when I pick up and swing an object fast enough near a wall it will go straight through.

Here's how I'm moving the object:

 ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
 newPos = ray.GetPoint(objectToPlayerDistance);
 Vector3 velocityDirection = (newPos - pickedObjectTransform.position) / Time.deltaTime;
                 
 pickedObjectrigBody.velocity = velocityDirection;

The only other thing I've done to the rigid body is make the freezeRotation boolean true. I have noticed that the velocity stays at (0, 0, 0) when I'm holding an object. Could that be a contributing factor? I'm at a loss and have spent a good while trying to figure this out. Thanks in advance.

Comment
Add comment · Show 4
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 bruce965 · Aug 28, 2013 at 06:26 AM 0
Share

Actually I didn't really understand your situation (probably because I just woke up), but I guess moving your code from "Update" to "FixedUpdate" might solve the problem.

avatar image MarcusDLB · Aug 28, 2013 at 09:16 PM 0
Share

The code is already in fixed update. Sorry I should have specified.

avatar image MalachiteBR · Aug 30, 2013 at 04:26 PM 0
Share

why don't you child the object to your character, so it will move together?

avatar image Ahaiziah · Jun 28, 2015 at 04:42 AM 0
Share

@malachite I want to the same but ive checking for code on how to it

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by EBR · Aug 28, 2013 at 10:06 PM

I think you are looking for this (http://wiki.unity3d.com/index.php?title=DontGoThroughThings) :)

Comment
Add comment · Show 4 · 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 MarcusDLB · Aug 29, 2013 at 05:04 AM 0
Share

Unfortunately it didn't work :/

I made a small video showing my problem. Slow collisions work fine but when holding an object and turning towards a wall the object goes straight through. Could this be a result of the way im moving the object?

http://www.youtube.com/watch?v=zGk1Ja3C$$anonymous$$7Q

avatar image graslany · Aug 29, 2013 at 05:56 AM 0
Share

Have you checked that the collision detection modes of your colliders are set according to this ?

avatar image MarcusDLB · Aug 29, 2013 at 08:18 PM 0
Share

Collision detection mode for the object that I picked up is set to continuous dynamic but I don't know about the wall. I'll check when when I get home. Otherwise I guess ray casting is the best route to take.

avatar image Rukas90 MarcusDLB · Nov 04, 2016 at 02:02 PM 0
Share

I know, I'm late to this, but I have same problem right now.. Have you solved this issue?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Player Clipping into Wall on collision,Player Clipping into Walls 2 Answers

Player character clipping through box collider 0 Answers

Player jumping from wall sometimes jump even when not collided with other wall 0 Answers

Unreliability of Physics.Raycast.Distance for player movement? 0 Answers

Player shaking when colliding with objects 3 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