Search Unity

RPG starter kit and player killed at start

Discussion in 'Editor & General Support' started by MrMajorThorburn, Jan 11, 2021.

  1. MrMajorThorburn

    MrMajorThorburn

    Joined:
    Dec 15, 2014
    Posts:
    89
    I am doing some learning using the RPG starter kit but have done something that is causing me this problem.
    When I select play the game starts and the scene show the player who then gets killed by an enemy.
    I have tried making the enemies folder inactive which does make the enemies disappear but the player still dies.
    I am at the point in the learning where dialogues get used when the player approaches a NPC but I cannot test that because the player dies before I get to move it.
    If I select the game window before I hit play the player is not in the same are as the scene where he dies so I am assuming there is some sort of spawn happening but cannot seem to find where that is.
    I realise I could just start from the beginning scrapping this project and going through the whole learning again but I am hoping someone may have a hint or three for me.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,736
    It might be something super simple like your health starting off at zero, then getting checked a moment later.

    To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

    Doing this should help you answer these types of questions:

    - is this code even running? which parts are running? how often does it run?
    - what are the values of the variables involved? Are they initialized?

    Knowing this information will help you reason about the behavior you are seeing.

    Looking on the bright side, this will have the side effect of helping you get more familiar with the codebase.
     
  3. MrMajorThorburn

    MrMajorThorburn

    Joined:
    Dec 15, 2014
    Posts:
    89
    Thanks for the response. I was intending to go through all the scripts after the learning lectures and will drop in Debug.Log's if I need to see 'live' details.
    I have found the spawnPoints in the scene and the script that places the player (SceneManagement/Portal.cs) so should be able to sort myself out now.
     
  4. MrMajorThorburn

    MrMajorThorburn

    Joined:
    Dec 15, 2014
    Posts:
    89
    Spoke to soon.
    The spawn points are not being used as indicated by no output from my Debug.Logs.
    I am working my way, slowly, through all the code to try to find out why the player is where it is at the start of play.
    At the moment he starts right next to an enemy and gets killed in less than a second.
    The player position before starting play is on the bridge and that is nowhere near any enemies.
    I am struggling here.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,736
    This is an excellent strategy in general.

    Without having looked at the RPG kit or any tutorials for it, let me give you some extra hints to dig into:

    - somewhere there is code that "finds" or "locates" those spawnpoints. Track that code down and see how it works. Are the spawnpoints dragged into a public list? Is there a special "Hey I am a spawnpoint!" script on each one? What is the mechanism by which they are supposed to be recognized?

    - somewhere the player is emplaced into the game (already in scene? Instantiated at a position? something else?). Check the order in which those two things execute, and obviously a Debug.Log( "I am at X!") type approach will get you some instantaneous information.

    And obviously, if the player's spawn location choice is not explicitly derived from the spawn point(s), the player won't be where you expect, so try to track down how that is supposed to happen.

    Perhaps others here have actually tried that tutorial and can weigh in on how it works?
     
  6. MrMajorThorburn

    MrMajorThorburn

    Joined:
    Dec 15, 2014
    Posts:
    89
    Ok, so I disabled the Enemies but the player still died.
    I am working my way through all the code finding where the players health is decreased but in the mean time I have changed the Die function to do a health regeneration and return;
    That has allowed me to continue with the Dialogue UI which is where my training has got to.
    I will revisit this dying player at start situation once I have completed my training (provided it does not get back to me again).
    I will update this topic with what I find once I have solved this or if I get stuck and need more help.
     
    Kurt-Dekker likes this.
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,736
    I actually found a few of these... can you tell me which one you're using for this?