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 Jonathan Genesis · Sep 16, 2013 at 09:43 PM · move an objectwont stop

picked up objects go through walls

Hello so i have the player able to pick up a cube. But when the player goes to the wall the cube docent stop at the wall it just goes through. I want the cube to stop at the wall. the cube for moving the cube to the player is:

 `    rigid.transform.localScale = Vector3(1,1,1);
     rigid.renderer.material = Capture;
     rigid.rigidbody.useGravity = false;
         rigid.MovePosition(transform.position + transform.forward * holdDistance);`
Comment
Add comment · Show 2
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 ShadoX · Sep 16, 2013 at 10:53 PM 0
Share

Have you tried moving it differently? (force, for example) I have never used http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.$$anonymous$$ovePosition.html but I have a feeling that you're simply setting the cubes position which is the reason why it goes through the wall.

avatar image Paparakas · Sep 17, 2013 at 03:47 AM 0
Share

I don't know why I laughed so hard at "the cube for moving the cube to the player"

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Croser · Sep 16, 2013 at 11:56 PM

Put another camera as a child of the main camera.Make a new layer. Set the child cam's culling mask to that new layer. Set the depth of the child camera to 1 and Clear Flags to 'Don't Clear'. Then, once picked, change the picked objects layer to the one you made the child camera see.

Here's what the function in my 'Pick_Me_Up_Bro.js' looks like.

     function PickMeUp(){
     transform.parent = PageHolder;
     transform.position = PageHolder.position;
     transform.rotation = PageHolder.rotation;
 //Here's the layer changing line.
     transform.gameObject.layer = LayerMask.NameToLayer("Pages");
     Picked = true;
     if(EventActivator){
     EventHolder.active = true;
     }
     }
Comment
Add comment · Show 2 · 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 Jonathan Genesis · Sep 17, 2013 at 12:29 AM 0
Share

I know how to make the object visible through walls but this doesn't do what i want i want it so stay behind the wall not go through and still be able to see it.

avatar image Croser · Sep 17, 2013 at 01:09 AM 0
Share

In that case you could use Lerp to keep the object in desired position, if I'm not mistaken this should also prevent it from going trough walls and stuff.

Something like this.

 transform.position = Vector3.Lerp(transform.position, target.position, delay);

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

18 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

Related Questions

Predefine player movement in game? 0 Answers

Issue with Collisions due to Parenting script 0 Answers

How would you set up a Lobby Scene? 1 Answer

Make Object smoothly follow player if out of near range 1 Answer

Why does a Rigidbody move correctly on an animated Rigidbody? 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