Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Disable Player Object?

Discussion in 'FPS.Sample Game' started by insane245, Dec 2, 2018.

  1. insane245

    insane245

    Joined:
    Jun 28, 2016
    Posts:
    2
    I was trying to implement a vehicle using the standard terraformer. The way that it's set up, it has a bunch of game objects instantiated on run. How could I pause the player state, disable it, and re-enable at another location? It's a lot trickier to do when not a single game object.

    Also, where in the project do I change what happens during run? I haven't been able to find the code where it spawns the player.

    Thank you!
     
  2. MasonEntrican

    MasonEntrican

    Joined:
    Sep 11, 2013
    Posts:
    8
    Before anyone can help I think we need a more clarification. Are you trying to disable the player object, replace the model of the player object with a car, or replace the player controller itself with a car controller along with the model?
     
    insane245 likes this.
  3. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    165
    Love it, I am also working on a project that will include vehicles as well... heavily. :) (so i'll post more as I progress)

    I found a lot of The Scripts from running in preview mode, then clicking on what I am looking inside the Scene view of the running preview game, and then hunting down the components being used as its running, then finding the scripts when no longer in play mode... :D

    Sooo... it may not be a surprise, But I believe they live in Assets > Scripts

    You could add a car model to the player, but disable its renderer, when you then swap the enabled renderer (from character to car) you would get a car moving around at the same x/y/z and speed/abilities as the character does.. so you would also need to modify or use another input controller to get the car to act like a car (top paying taxes, stop eating all your food, starts running on gas.)

    Because I am going to want to allow the player to move within the car (crawl between seats, shoot out), and be killed when shot within the car, it will get more complicated :D!

    Good Luck, Have Fun
    Micah
     

    Attached Files:

    insane245 likes this.
  4. insane245

    insane245

    Joined:
    Jun 28, 2016
    Posts:
    2
    Thanks for the replies! Micah, I watched your scene setup video and enjoyed it! Thanks for the help. I'm working on flight game. So when the player is close to the plane, hit a button and disable the controller. Now enable the plane controller. I'll try to fiddle around and do what you suggested! I feel like that would work. I need to work on disabling scripts without the console yelling at me!

    As for the scripts, I see what you're saying, but I'm still a bit confused. Usually in Unity you need a gamemaster object in order to run global scripts like spawning. But as per your scene setup video, it just spawns the character automatically? Where in the scene is it triggering this code?

    Thanks for your help!
     
  5. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    165
    Hello Insain245, that's super cool you saw the video! I placed this reply in that video as well, thank you!

    I believe that since I am running/executing the game already(not preview mode), and I select a level to load, that the gameplay logic is already up and ready with the fps example, separate from the scenes.

    Then when you load a level, the engine/game looks for items to use with that logic, like spawn points, capture zones, ect. But my new level, does not have any of that (spawn locations/zones/gamplayhere), so I believe(have not looked at the code) the default state of the spawners and such game scripts, will dump things (players) at 0,0,0 when you load a game level without any of that spawner/zone details found/defined. Which is great, otherwise you would have to know more to get things running at the smallest level... such as level_04 is !

    If you load up level_00 in the editor, its pretty clean/basic, you can look at the intended spawn points and capture zones details within that level, which I will then modify and copy/migrate to the new level to act as you want. I found it problematic to copy level_00 into level_04's directory, to try and make a copy of the level to edit... soooo instead I'm starting out with a clean/known environment (level_04), instead of trying to modify an existing level filled with unknown(level_01/00.)

    Then I go into the existing levels, and pull stuff out, into my known environment (level_04.)

    Cheers,
    Micah
     

    Attached Files:

    keeponshading likes this.