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 /
This question was closed Jan 29, 2014 at 05:06 AM by AlucardJay for the following reason:

Duplicate Questions : http://answers.unity3d.com/questions/623453/stopping-moving-object-going-through-a-wall.html : http://answers.unity3d.com/questions/612537/how-to-stop-my-object-from-going-through-another-o.html

avatar image
0
Question by a_flux · Jan 29, 2014 at 04:34 AM · collisionmovementcolliderstoprigidbody-collision

Object going through another....How to solve it?

Dear All,

This is my 3rd question regarding this issue, I have an object (probe) that responds to mouse clicks, and I have a wall (cube) standing on the terrain (floor). My problem is that when I click on the wall the probe moves towards that point and some of it's tip goes into the wall which i don't want to see, I want my probe to reach the surface of the wall and stops. I did apply rigid body and box and mesh colliders to both, the probe and the wall and it sort of stopped the probe from going through the wall but now when the probe reaches and touches the wall it starts shaking and dragging along the wall in a funny way, I want my probe to touch the wall and stay put with out shaking or dragging movement even though it moves and shakes very slowly. How to overcome this problem. Any help will appreciated. Cheers

Comment
Add comment · Show 5
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 frogsbo · Jan 29, 2014 at 04:42 AM 0
Share

is physics being overriden by positioning code?

avatar image a_flux · Jan 29, 2014 at 04:57 AM 0
Share

Sorry mate, but I am totally new to unity, do u mean applying physics to my code? if that's what u mean then No, otherwise please clarify. To cut down the chase I am attaching my code for you to check it, I am crap in coding too. Here it is:

var smooth : float = 1.0; // Deter$$anonymous$$es how quickly object moves towards position private var targetPosition : Vector3; var speed : float = 60.0;

function Start() { targetPosition = transform.position; }

function Update () {

 if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.$$anonymous$$ouse0)) {
   

     var playerPlane = new Plane(Vector3.up, transform.position);
     var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
     var hitdist = 0.0;
    
     if (playerPlane.Raycast (ray, hitdist)) {
         var targetPoint = ray.GetPoint(hitdist);
         targetPosition = ray.GetPoint(hitdist);
         var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
         transform.rotation = targetRotation;
     }
 }

 var dir : Vector3 = targetPosition - transform.position;
 var dist : float = dir.magnitude;
 var move : float = speed * Time.deltaTime;
 if(dist > move){
     transform.position += dir.normalized * move;
 } 
 else {
     transform.position = targetPosition;
 }
 
 transform.position += (targetPosition - transform.position).normalized * speed * Time.deltaTime; 

}

avatar image AlucardJay · Jan 29, 2014 at 05:04 AM 0
Share

DO NOT POST DUPLICATE QUESTIONS :

  • http://answers.unity3d.com/questions/612537/how-to-stop-my-object-from-going-through-another-o.html

  • http://answers.unity3d.com/questions/623453/stopping-moving-object-going-through-a-wall.html

You have been advised by many people :

1/ submit your code when asking a question

2/ that modifying a transform is like teleporting a gameObject to a specified position, SO IT WILL NOT BE AFFECTED BY COLLISIONS. USE FORCE AND RIGIDBODY.

avatar image a_flux · Jan 29, 2014 at 05:06 AM 0
Share

Thanks for closing the question, but did you check that there is no one is replying back or trying to help me out with the previous one and that's why i had to ask a new one...

avatar image a_flux · Jan 29, 2014 at 05:08 AM 0
Share

Cheers for the tip.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

19 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

Related Questions

Transforming position for different colliders for repeating background? 0 Answers

Colide objects with runtime gizmo movement 0 Answers

Object collider not operating properly 2 Answers

Stopping my player from moving when hitting a wall. 5 Answers

Sinking Sand 2 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