Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2011
    Posts
    1

    Question 19 - Player Destruction unable to implement

    I followed everything showed on your videos so far.. I am on the 19th video regarding player destruction.. However, the code is not working. I have followed all the steps but still it is not registering the trigger at all..

    I am not from a programming background so having trouble figuring out what is missing or what is wrong..

    Would appreciate some guidance

  2. #2
    Join Date
    Feb 2014
    Posts
    277
    I still have these scripts and when the player is hit it does blow up, so the code in the training video is correct.
    I assume you have no compiler errors.

    For starters, check that Player.cs trigger method line is exactly like this:
    void OnTriggerEnter(Collider otherObject)
    As you are no doubt aware, capitalization has to be 100% correct in C# so make 101% sure you have it letter for letter.

    Put in a Debug.Log line in just after it to tell the console if that method is being called.
    Debug.Log("Player was hit");
    If that console message doesn't display when the player is hit, then I'd be checking that the Enemy prefab has the Sphere Collider on it and that "IsTrigger" is ticked. Run the game and pause it. Check that the Enemy Sphere Collider is centred on the Enemy object and big enough to cover the entire enemy object.

    Finally, make sure the Player has a Box Collider on it. IsTrigger doesn't have to be ticked on the player but check that the Box Collider is centred on the player and is big enough to cover the entire player.

    I hope that helps. As frustrating as it seems, problems are opportunities to learn something and if you solve it, then you have accomplished a lot more than just typing in code from a training video.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •