E
E
Egor Gavrilenko2020-06-12 08:17:56
C++ / C#
Egor Gavrilenko, 2020-06-12 08:17:56

How to make an object not pass through other objects?

I have a cube that, when clicked on Mouse0, teleports to the point where Arm is located. When I hover and click on the cube, these actions occur:

if (Raycas.rc==true)
        {
            myText.SetActive(true);
            outline.enabled = true;

            if (Input.GetKeyDown(myKey))
            {
                transform.position = arm.position;
                transform.SetParent(arm);
                rb.useGravity=false;
                rb.constraints= RigidbodyConstraints.FreezeAll;
            }
        }
        if(Raycas.rc==false)
        {
            myText.SetActive(false);
            outline.enabled = false;
        }
       
        if (Input.GetKeyDown(myKey))
        {
            transform.position = arm.position;
            
        }
        if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            rb.useGravity = true;
   
            transform.SetParent(null);
            rb.constraints = RigidbodyConstraints.None;
        }
    }

The code itself is in the cube.
Attention I'm a beginner, please describe in more detail.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question