K
K
Kifoter2021-10-02 19:46:51
Unity
Kifoter, 2021-10-02 19:46:51

How to make a child object not respond to collisions?

I have a character and a sword in the game. The main character also has a sword. According to the code, the enemy dies in case of contact with the sword. But when I added a sword to the enemy, he began to die if the main character's sword touches the enemy's sword. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BFGunner, 2021-10-03
@BFGunner

Need a code.
I will assume that you are checking contact with the enemy collider.
Exit - you can check the collider with a certain tag. Then the enemy will have 2 colliders:
1. A sword collider with the Weapon tag. Responsible for contact with the collider of player
2. The collider of the enemy with the Enemy tag. It is the contact with the Enemy collider that will be responsible in the script for causing damage

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question