Hurt Player Continuously When Enterring Trigger Unity

2 Answers 2

Alternatively (for those people who want or need gravity enabled on their cubes):

Add a second collider.

Two colliders, one box

There's literally nothing stopping you from doing this. You can make the trigger one bigger or just tweak the physics layers collision settings so that the collider keeping the enemies on the ground doesn't interfere with the operation of colliding with the player, etc.

Community's user avatar

answered Jun 13, 2017 at 13:44

Draco18s no longer trusts SE's user avatar

7

  • The idea of making the cube a trigger is to make sure the player does not collide with the cube. The cube is like a coin in mario games. Imagine colliding with the coins. That would ruin the gameplay. The cube is also rotating. That would affect the rotation of the cube. Also, attaching multiple colliders to one gameobject with different IsTrigger settings will introduce hard to cure bugs. If you need to use many colliders, they should be child of the gameobject not attached directly to the gameobject. Finally, you should never attach the-same type of collider to the-same GameObject.

    Jun 13, 2017 at 17:50

  • It really depends on the use-case. You can make the trigger volume larger than the collider volume (which only needs to be large enough to keep it from falling through the floor). As for "never attach the same type of collider to the same GO": I disagree. Unity themselves even point out that using 3 box colliders for a rifle is much more performant than a single mesh collider and achieves comparable results: each one just has a different size and offset.

    Jun 13, 2017 at 17:54

  • "You can make the trigger volume larger than the collider volume (which only needs to be large enough to keep it from falling through the floor" You don't understand. This won't work because the cubes are spinning. The cubes are meant to stay in one place but spin endlessly. If you do this and they touch the floor, they will move their position and it will also interfere with their spinning since they are colliding with the floor. Both of these we don't want in the gameplay.

    Jun 13, 2017 at 18:34

  • "Unity themselves even point out that using 3 box colliders for a rifle is much more performant than a single mesh collider and achieves comparable results" This is called "Compound Colliders" and I agree with that. You don't understand my comment. You should not attach multiple colliders to the-same GameObject. You should put each collider as a child GameObject of that mesh. Don't attach several collides to the-same GameObject. Your answer is showing many colliders on one Object. This is wrong!

    Jun 13, 2017 at 18:35

  • Quote from Unity "To create a Compound Collider, create child objects of your colliding object, then add a Collider component to each child object." By the way, this is the step OP missed.

    Jun 13, 2017 at 18:35

It's likely that the cube is on top of the floor. When you enable "Is Trigger", collision is disabled and the cube would go through the floor.

The solution is to disable "Use Gravity" on the cube's Rigidbody.

enter image description here

Note that you are following a plagiarized version of the original "Roll-a-ball tutorial" tutorial which left out so many things. You should be following the original tutorial here. Watch the 10 seconds from this video which describes what you missed which is what I described above.

answered Jun 13, 2017 at 9:21

Programmer's user avatar

7

  • No it's the exact other way. "is Trigger" off = cube sitting perfectly on the ground, moving as intended. "is Trigger" on = cube falls through the floor. Gravity is checked.

    Jun 13, 2017 at 9:25

  • That was a typo. I meant to say "enable" not "disable". Please try the answer before making further comments. That will prevent unnecessary comments.

    Jun 13, 2017 at 9:27

  • Ah ok. Well then I'll just disable it again. As for the linked tutorial... I totally dislike video tutorials as it is a huge pain to re-view specific stuff as you can't just scroll or ctrl+f to back to something you wanted to reread... but also I CAN NOT view video tutorials as I am making this little thing in a medical rehab.

    Jun 16, 2017 at 6:31

  • Well the tutorial you are following left that out and I think they will leave many other things out. You can scroll videos on Youtube videos by dragging the mouse over the timeline. You can fast-forward and re-wind too but since you don't like video tutorials, I don't think that would be helpful.

    Jun 16, 2017 at 6:42

  • But if I need gravity?

    Sep 18, 2017 at 14:02

hopperhaile1990.blogspot.com

Source: https://stackoverflow.com/questions/44517031/unity-activating-is-trigger-makes-stuff-fall-through-objects

Belum ada Komentar untuk "Hurt Player Continuously When Enterring Trigger Unity"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel