1
\$\begingroup\$

I have two dots/points that move onto the screen at start. I have a pencil move and when collide with the points the pencil writes which all works ok.

My problem is when the pencil RigidBody hit the RigidBody of the point, the point gets pushed out fo position. I cant change the point RigidBody to static because I need to move it at the start.

pencil script

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.name == "Point")
    {
        writing = !writing;
    }
}
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

That's because the two bodies behaving two solid object so when they collide there will impact of collision. instead change your objects from solid to trigger by checking "is Trigger" check box at collider settings like:

enter image description here

Now there will be no impact of collision but you have to change you script like this:

private void OnTriggerEnter2D(Collider2D collision)
{
     if (collision.name == "Point")
     {
         writing = !writing;
     }
}

Also don't do comparison on name instead use Tags. if you need more information on this pleas let me know.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .