Search Unity

Switching Between Characters

Discussion in 'Getting Started' started by unity_0D3xqHrJWNie6Q, Sep 26, 2018.

Thread Status:
Not open for further replies.
  1. unity_0D3xqHrJWNie6Q

    unity_0D3xqHrJWNie6Q

    Joined:
    Sep 24, 2018
    Posts:
    8
    I am new to unity and wanted to make a 2D game. I want to be able to switch between different characters. I was wondering is there a way to do this in unity if so how. I also have Playmaker installed. can someone help me, please.
     
  2. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358

    It depends on your design. If its flexible enough you can do it easy.
     
  3. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    You are going to need to provide a lot more details. Yes this completely possible and common, but without the specifics of your game, and what you have tried, it will be impossible to accurately answer your question.
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,184
    I highly recommend you start by going through the official tutorials if you haven't already because frankly you need to know the info they teach to get anywhere with Unity and based on your post I'm guessing you have little to no previous scripting experience let alone game development experience.

    We can try to help you but you're just going to get stuck again with the next step of your game if you don't learn the tools.
     
    Bill_Martini likes this.
  5. unity_0D3xqHrJWNie6Q

    unity_0D3xqHrJWNie6Q

    Joined:
    Sep 24, 2018
    Posts:
    8
    Ok i have used unity before, but not on a 2D game. I want to have 3 main character that when you hit specific key you change into them. Each Character has different abilities. For example, one character has an extra jump, one can swim in water, one can walk on fire. I want to switch between them. Kind of like game with: Trine, Party Of Sin, Lego series.
     
  6. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    You just need some clever abstraction. I often see people do

    if(Input.GetKeyDown("somekey")) directly in the actual character controller etc. This is NOT ok. You hard wire the controls directly into the every instance of that controller. If we ignore all the other antipattern in doing this it also creates problems for you since you want to switch character.

    So start by abstracting the controls into a strategy. You can have one AI strategy and one player strategy. Switch this out when you change player. (Because I guess you want AI to control it when you are not?)
     
  7. unity_0D3xqHrJWNie6Q

    unity_0D3xqHrJWNie6Q

    Joined:
    Sep 24, 2018
    Posts:
    8
    I just want the other character to disappear from screen.
     
  8. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    Destroy(otherGameObject);

    Maybe you need to complete a few of Unity's tutorials, see the Learn link above.
     
  9. unity_0D3xqHrJWNie6Q

    unity_0D3xqHrJWNie6Q

    Joined:
    Sep 24, 2018
    Posts:
    8
    It doesn't have say how to switch characters, which is the key component to my game.
     
  10. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    I think you need to pick a question and ask that. You stated;

    And I responded;

    Now you change the question. If you spend some time completing several of Unity's tutorials all your confusion about this will disappear. Forget about your game right now and learn to make a game, any game, but make it simple, it needs to be a complete game ready for publishing. Do that a couple more times and you'll be ready to start your original game.
     
  11. unity_0D3xqHrJWNie6Q

    unity_0D3xqHrJWNie6Q

    Joined:
    Sep 24, 2018
    Posts:
    8
    ok thanks i got it now. I don't have a lot of time to learn or go through the tutorials. I just need the code for playmaker, then i can do some individual research and improve it slightly. It's for coursework.
     
  12. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    No one is going to do your home work for you. I'm having a hard time believing courses are teaching playmaker. Learn to code! Playmaker or any other visual scripting scheme still relies on logic and the ability to break down a problems into small steps, which is the hardest part of coding. You can't escape the reality, you need to learn to code, visual scripting is not a professional way to proceed, and you'll spend as much time learning either. You seem to be looking for shortcuts, there are none.
     
  13. unity_0D3xqHrJWNie6Q

    unity_0D3xqHrJWNie6Q

    Joined:
    Sep 24, 2018
    Posts:
    8
    I understand. But our teacher wants us to learn to code through playmaker. I did basic coding in secondary, using python, but that still isn't enough to learn from.

    For the record i found a way to do it. I have an empty object and out my players into there, then put the script into the empty object. I had only one issue the C+ worked with a Gui button, but i managed to get it to work with playmaker activating scripts. So thanksss.
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Try the playmaker forums, which are for this specific purpose. Good luck!

    https://hutonggames.com/playmakerforum/index.php
     
  15. Green11001

    Green11001

    Joined:
    Apr 14, 2018
    Posts:
    397
    Ummm you could disable one player and enable the other
     
Thread Status:
Not open for further replies.