Skip to content

Instantly share code, notes, and snippets.

@nhaskins
Created February 4, 2019 19:17
Show Gist options
  • Save nhaskins/d525aa6e3deb3518045b9efc09dbeb29 to your computer and use it in GitHub Desktop.
Save nhaskins/d525aa6e3deb3518045b9efc09dbeb29 to your computer and use it in GitHub Desktop.
World.s
using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.ThirdPerson;
using UnityStandardAssets.Cameras;
namespace BunnyGun {
public class World : MonoBehaviour {
public GameObject[] characters;
GameObject currentCharacter;
int charactersIndex;
void Start(){
charactersIndex = 0;
currentCharacter = characters[0];
}
void Update () {
if(Input.GetButtonDown("Fire1")){
charactersIndex++;
if(charactersIndex == characters.Length){
//end of index, go back to start
print("fired loop check");
charactersIndex = 0;
}
currentCharacter.GetComponent<ThirdPersonUserControl>().enabled = false;
characters[charactersIndex].GetComponent<ThirdPersonUserControl>().enabled = true;
GameObject.Find("camera").GetComponent<AutoCam>().myTarget = characters[charactersIndex].transform;
currentCharacter = characters[charactersIndex];
//enable player 2 controller
}
// if(Input.GetButtonDown("Fire2")){
// //left alt key or B
// print("pressed Fire2");
// }
// if(Input.GetButtonDown("Fire3")){
// //left alt shift or X
// print("pressed Fire3");
// }
// if(Input.GetButtonDown("Jump")){
// //left alt shift or Y
// print("pressed Jump");
// }
// if(Input.GetButtonDown("Submit")){
// //Enter or A
// print("pressed Submit");
// }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment