U
U
Uncle Bogdan2021-05-04 22:35:57
Unity
Uncle Bogdan, 2021-05-04 22:35:57

Why does an object increase from touching another, although this is not indicated in the code?

Here is a video: https://youtu.be/wu4xvhZfG6E
For some reason, the object is increasing.
The code:

The code
using UnityEngine;

public class MotherBoardPlace : MonoBehaviour
{

    Collision collision;

    private void OnCollisionEnter(Collision collision)
    {
        this.collision = collision;
        switch(collision.collider.tag)
        {
            case "Processor":
                Place("ProcessorPlace", new Vector3(0, 0, 90));
                break;
            case "ram":
                Place("RamPlace", new Vector3(-90, 0, 90));
                break;
        }
    }

    private void Place(string TagName, Vector3 Angle)
    {
        collision.rigidbody.isKinematic = true;
        collision.rigidbody.detectCollisions = false;
        collision.rigidbody.useGravity = false;
        collision.transform.parent = transform;
        collision.transform.eulerAngles = Angle;
        collision.transform.localPosition = transform.Find(TagName).localPosition;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-05-04
@motkot

collision.transform.parent = transform;

Because the parent is applied to itscale

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question