Welcome!

Welcome to our community forums, full of great people, ideas and excitement. Please register if you would like to take part.

This is extra text with a test link..

Register Now

Announcement

Collapse
No announcement yet.

Player won't die when he falls off platform

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Player won't die when he falls off platform

    Incase I can find help here, I am having a lot of issues but this is one I'm trying to tackle. I tried making a large cube below the main platform, applied a collider, marked it as a trigger, and turned off the mesh. I wrote this script to see if it would kill the player (angry cardinal) if he fell off and hit the collider but the message doesn't print or it just doesn't work. I was thinking this script would work being applied to the "trigger" (invisible platform), or maybe to the "player" (angry cardinal) but not much luck. Any suggestions or help is much appreciated.

  • #2
    If you're using a trigger, you need to use OnTriggerEnter (not OnCollisionEnter). But you're on the right track.

    I'm also moving this to the Unity forum as it's really a unity question and not a question about the class.

    Comment


    • #3
      I remade the script and applied it to the "trigger", however I am still getting a lot of errors that seem to come from my BadGuyscript for some reason (that is where the console messages take me). I also included a screenshot of the new script I wrote that has OnTriggerEnter.

      Comment


      • #4
        You're getting the errors because your new DestroyPlayer script works. The problem is that your new OnTrigger script destroys the player (AngryCardinal), but you've told all your badguys to look at AngryCardinal (which doesn't exist anymore).

        Change your DestroyPlayer so that it doesn't Destroy the player, and instead jumps to another You Won or You Lost level, and you'll be fine. Or for now, just remove the Destroy(col.gameObject) line and you should be fine.
        Last edited by Professor Watkins; March 12, 2021, 08:25.

        Comment


        • #5
          I got it! Thank you!

          Comment

          Working...
          X