From e16a46bd57225f12cc6149e09d34b042e6ce5600 Mon Sep 17 00:00:00 2001 From: thedonaldloughry Date: Sat, 30 Jan 2016 01:10:45 -0500 Subject: [PATCH] Attempting to commit framework code and character controller. Please work. - Don --- Assets/Resources/Materials.meta | 9 ++ .../Resources/Materials/Object_Materials.meta | 9 ++ Assets/Resources/Materials/Physics.meta | 9 ++ .../Physics/Main_Character.physicsMaterial2D | Bin 0 -> 4152 bytes .../Main_Character.physicsMaterial2D.meta | 8 ++ Assets/Resources/Scenes/TestScene.unity | Bin 25712 -> 22144 bytes Assets/Resources/Scripts/Character.cs | 15 --- Assets/Resources/Scripts/Controller.cs | 79 ++++++++++++ .../{Character.cs.meta => Controller.cs.meta} | 4 +- Assets/Resources/Scripts/GameManager.cs | 59 +++++++-- Assets/Resources/Scripts/InputManager.cs | 114 ++++++++++++++++++ Assets/Resources/Scripts/InputManager.cs.meta | 12 ++ Assets/Resources/Scripts/PlayerCharacter.cs | 67 ++++++++-- Assets/Resources/Scripts/Utilities.cs | 44 ++++++- ProjectSettings/InputManager.asset | Bin 5520 -> 6288 bytes ProjectSettings/Physics2DSettings.asset | Bin 4308 -> 4308 bytes ProjectSettings/TagManager.asset | Bin 4320 -> 4344 bytes 17 files changed, 386 insertions(+), 43 deletions(-) create mode 100644 Assets/Resources/Materials.meta create mode 100644 Assets/Resources/Materials/Object_Materials.meta create mode 100644 Assets/Resources/Materials/Physics.meta create mode 100644 Assets/Resources/Materials/Physics/Main_Character.physicsMaterial2D create mode 100644 Assets/Resources/Materials/Physics/Main_Character.physicsMaterial2D.meta delete mode 100644 Assets/Resources/Scripts/Character.cs create mode 100644 Assets/Resources/Scripts/Controller.cs rename Assets/Resources/Scripts/{Character.cs.meta => Controller.cs.meta} (76%) create mode 100644 Assets/Resources/Scripts/InputManager.cs create mode 100644 Assets/Resources/Scripts/InputManager.cs.meta diff --git a/Assets/Resources/Materials.meta b/Assets/Resources/Materials.meta new file mode 100644 index 0000000..153908f --- /dev/null +++ b/Assets/Resources/Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8f80300c8efcde24894c3c89a8c393bc +folderAsset: yes +timeCreated: 1454133135 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Materials/Object_Materials.meta b/Assets/Resources/Materials/Object_Materials.meta new file mode 100644 index 0000000..5102cda --- /dev/null +++ b/Assets/Resources/Materials/Object_Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fcea9ce4bc0c3c74d8a3299271a8702c +folderAsset: yes +timeCreated: 1454133156 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Materials/Physics.meta b/Assets/Resources/Materials/Physics.meta new file mode 100644 index 0000000..e8010ab --- /dev/null +++ b/Assets/Resources/Materials/Physics.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b6795327771d1f94dbd3e765cbdfb2ec +folderAsset: yes +timeCreated: 1454133142 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Materials/Physics/Main_Character.physicsMaterial2D b/Assets/Resources/Materials/Physics/Main_Character.physicsMaterial2D new file mode 100644 index 0000000000000000000000000000000000000000..6d8497f2b157602906bee8975fcb9d00f204b306 GIT binary patch literal 4152 zcmeH~&q~8U5XNT{|J1(~@uV-HmqHa$M2gT>^iYWppe4qXuGAEg6cjHx3BH0iFJ8QP z6Fi9c1|r@BUqL(@zuAVGcW@FWyYt)0x07#AAyQvNGwVcD#E5}twX{+yx61UBrm0c@ z6-4pjd;a~gcd_*Pd^LAa_?!mYL-0CZYeWg^Q)wXb1Xt(Bb}h50!AQ zmcpLAui<0Nx0u_e&jq~0eU39XVbeZpPY|3>47j2junpu~&)>`+!u>O^W_&8+PWwF4 zUes`7Kh$n#xkio?hnw|d9e2a}S?mXq?gkY)ZEow1zgxq^apN{7tx$V0*666)3p^e8 zQDi!!r|Ux&Hy0l?A7_QKqv~UMiUZ<+I3Ny)1LA-Y!O| MyP@mhhxE^kU-Wud;Q#;t literal 0 HcmV?d00001 diff --git a/Assets/Resources/Materials/Physics/Main_Character.physicsMaterial2D.meta b/Assets/Resources/Materials/Physics/Main_Character.physicsMaterial2D.meta new file mode 100644 index 0000000..b05d9ca --- /dev/null +++ b/Assets/Resources/Materials/Physics/Main_Character.physicsMaterial2D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c1198204bc64ae347b6e0a54aef13a9b +timeCreated: 1454133168 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Scenes/TestScene.unity b/Assets/Resources/Scenes/TestScene.unity index f56c58036238c66b6c0fe8326d4237b5e4b69049..75eaa77ea5aff86574b2b5aaeef8b3f59ed5cf07 100644 GIT binary patch delta 1777 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 LysOGzm#O~(0hXD( diff --git a/Assets/Resources/Scripts/Character.cs b/Assets/Resources/Scripts/Character.cs deleted file mode 100644 index 625c457..0000000 --- a/Assets/Resources/Scripts/Character.cs +++ /dev/null @@ -1,15 +0,0 @@ -using UnityEngine; -using System.Collections; - -public class Character : MonoBehaviour { - - // Use this for initialization - void Start () { - - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/Assets/Resources/Scripts/Controller.cs b/Assets/Resources/Scripts/Controller.cs new file mode 100644 index 0000000..81d837d --- /dev/null +++ b/Assets/Resources/Scripts/Controller.cs @@ -0,0 +1,79 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using GameUtils; + +/// +/// The base "controller" class defines axes of movement, speed of movement, and the controls needed to +/// move a character in 3D space. To extend this to either first or third person control, axes of movement +/// are always defined according to the camera. +/// +public class Controller : MonoBehaviour +{ + public float movementSpeed, turnSpeed, groundCheckDistance; // speeds set in editor, intensity from iManager. + + [HideInInspector] + public bool onGround, canJump, wallDetected; + + [HideInInspector] + public Collider2D characterCollider; + + [HideInInspector] + public List collPointList; // This is the useful thing for us... + + [HideInInspector] + public float movementIntensity; + + [HideInInspector] + public Vector2 movementVector; + + [HideInInspector] + public Dictionary gameInputMap; + + [HideInInspector] + public Camera mainCamera; + + [HideInInspector] + public bool groundCast, isBoxColliding; + + private Vector3 commonGroundSearchPoint; + private Vector2 jumpCheckObjectPosition; + private Transform jumpCheckObject; + + void Awake() + { + characterCollider = gameObject.GetComponent(); // Change this if collider shape changes. + jumpCheckObject = transform.Find("JumpCheckPosition"); + // Ground cast vectors are the positions on the bottom corners of the player's hitbox. We use these to determine + // if the player is on the ground, which is basic information to be used by derivative classes. + // Remember that the character's transform position is sitting on the center-top of its hitbox. + } + + void OnCollisionStay2D(Collision2D other) + { + isBoxColliding = true; + } + + void OnCollisionExit2D(Collision2D other) + { + isBoxColliding = false; + } + + void FixedUpdate() // Only ever runs at 30 fps, so we save some computation time on these casts at least... + { + Debug.DrawLine(jumpCheckObject.position, jumpCheckObject.position + -jumpCheckObject.up * groundCheckDistance, Color.green); + groundCast = Physics2D.Raycast(jumpCheckObject.position, -jumpCheckObject.up, groundCheckDistance); + print("Debug groundCast: " + groundCast); + if (groundCast && isBoxColliding) + { + onGround = true; + } + else + { + onGround = false; + } + } + + public virtual void HandleInput() { } // Note that one input should move the variable camera position object around the player... + +} diff --git a/Assets/Resources/Scripts/Character.cs.meta b/Assets/Resources/Scripts/Controller.cs.meta similarity index 76% rename from Assets/Resources/Scripts/Character.cs.meta rename to Assets/Resources/Scripts/Controller.cs.meta index 39fd4c8..3362cf4 100644 --- a/Assets/Resources/Scripts/Character.cs.meta +++ b/Assets/Resources/Scripts/Controller.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 04615787dccc1d642a748a80392b5b82 -timeCreated: 1454120443 +guid: eb4f819bc107d974f8c76f7cbec5ef15 +timeCreated: 1454122395 licenseType: Free MonoImporter: serializedVersion: 2 diff --git a/Assets/Resources/Scripts/GameManager.cs b/Assets/Resources/Scripts/GameManager.cs index fafc443..9ae8b37 100644 --- a/Assets/Resources/Scripts/GameManager.cs +++ b/Assets/Resources/Scripts/GameManager.cs @@ -1,15 +1,52 @@ using UnityEngine; using System.Collections; +using GameUtils; -public class GameManager : MonoBehaviour { +public class GameManager : MonoBehaviour +{ - - void Start () { - - } - - // Update is called once per frame - void Update () { - - } -} + public static GameManager gManager; // gManager for GameManager, iManager for InputManager, etc... + public static InputManager iManager; + + private GameObject[] tagged_objects; + private ISceneObject[] scene_objects; + + void Start() + { + if (gManager == null) + { + gManager = this; + iManager = new InputManager(0.1f, 0.2f); + tagged_objects = GameObject.FindGameObjectsWithTag("Scene_Object"); + scene_objects = new ISceneObject[tagged_objects.Length]; + iManager.Initialize(); + // Initialize the list of scene objects, all of which have ONE ISceneObject component. + for (int i = 0; i < tagged_objects.Length; i++) + { + scene_objects[i] = tagged_objects[i].GetComponent(); // Grab all of those scene objects! + } + + // Initialize all scene objects. + for (int j = 0; j < scene_objects.Length; j++) + { + scene_objects[j].Initialize(); + } + } + else + { + Destroy(gameObject); + } + } + + /// + /// Update all scene objects in one update loop. + /// + void Update() + { + iManager.ObjectUpdate(); + for (int j = 0; j < scene_objects.Length; j++) + { + scene_objects[j].ObjectUpdate(); + } + } +} \ No newline at end of file diff --git a/Assets/Resources/Scripts/InputManager.cs b/Assets/Resources/Scripts/InputManager.cs new file mode 100644 index 0000000..d403c81 --- /dev/null +++ b/Assets/Resources/Scripts/InputManager.cs @@ -0,0 +1,114 @@ +using UnityEngine; +using System; +using System.Collections; +using System.Collections.Generic; +using GameUtils; +using System.Diagnostics; + +/// +/// The game's input manager. Should behave as a singleton, as it is only created by the GameManager singleton. +/// Offers the public use of an input dictionary and movement information (vector, intensity, etc.) +/// +public class InputManager : ISceneObject +{ + public Vector2 movementVector, rightStickVector; // the final calculated movement vector, passed for handling to controller. + // typically, the movement of the left stick/WASD. + public float deadZone, rDeadZone, movementIntensity, rightStickIntensity; // How hard is the player pushing the stick in any direction? + public Dictionary gameInputMap; + + private Camera mainCamera; + private Vector2 inputUpVector, inputRightVector; // a normalized vector created from the literal horizontal/vertical input. + + /// + /// Initializes a high-level handler for input. Keeps a movement + /// vector that resets to 0 on no input, along with a + /// button dictionary reading input from Unity, so that you don't have to. + /// + /// The deadzone for joystick input. Not important for keyboard input. + public InputManager(float intendedDeadZone, float rightStickDeadZone) + { + deadZone = intendedDeadZone; // To pass this as a parameter, because I felt like it. + rDeadZone = rightStickDeadZone; + // We could just run Initialize() here, really... + } + + public void Initialize() + { + movementVector = Vector2.zero; + rightStickVector = Vector2.zero; + mainCamera = Camera.main; + gameInputMap = new Dictionary() { { GameInput.JUMP, false } }; // Add more input types as needed. + } + + /// + /// The input tracking functions defined below work only for standard Xbox360 controller layouts, as that is common + /// among gamers. For other types of controllers, more advanced methods of input tracking would be needed, most + /// likely by pulling info from a configuration text file. + /// + /// I also need to setup the other possible buttons/joystick axes in the Input Manager. I will return to do this + /// later, as for right now all I need to worry about it gameplay testing and mechanics. A pattern similar to the + /// one used below would be used for OSX, were I to tackle that today. + /// + /// Note that the left joystick never needs to be tampered with, as Unity's global Horizontal and Vertical buttons + /// act like axes and always seem to be mapped correctly. + /// + /// Also note: On Windows, using Xbox 360 controllers, the triggers are seen as one axis, the 3rd axis. This is by + /// design. + /// + /// "The triggers are seen as a single joystick axis with the R Trigger going from 0 to 1 and the L trigger going from + /// 0 to -1 on the same axis. If both are pressed at the same time they negate the effect of each other to offer a + /// "smooth accelration + break" effect (as racing games and games with similar acc / break schemes are the primary + /// reason for the triggers)." + /// + /// Check the InputManager for this project to see the available inputs for Windows. Note that these buttons need to + /// be set in the InputManager of any project that this controller is ported to. + /// + [Conditional("UNITY_EDITOR_WIN"), Conditional("UNITY_STANDALONE_WIN")] + private void TrackInput_Windows() + { + gameInputMap[GameInput.JUMP] = (Input.GetButton("Xbox360Controller_A") || Input.GetButtonDown("Xbox360Controller_A") || Input.GetButtonDown("Jump") || Input.GetButton("Jump")); + } + + [Conditional("UNITY_EDITOR_OSX"), Conditional("UNITY_STANDALONE_OSX")] + private void TrackInput_MacOSX() + { + UnityEngine.Debug.Log("You shouldn't see this..."); + } + + //... other input tracking methods will be needed to track input on different consoles and Linux. + + public void ObjectUpdate() + { + TrackInput_Windows(); + TrackInput_MacOSX(); + if (Input.GetAxis("Vertical") > deadZone || + Input.GetAxis("Horizontal") > deadZone || + Input.GetAxis("Vertical") < -deadZone || + Input.GetAxis("Horizontal") < -deadZone) + + { + movementVector = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); + UnityEngine.Debug.Log(movementVector); + movementIntensity = movementVector.magnitude; // Always 1 on keyboard, but not joystick! + } + else + { + movementIntensity = 0.0f; + movementVector = Vector2.zero; + } + + if (Input.GetAxis("RHorizontal") > rDeadZone || + Input.GetAxis("RHorizontal") < -rDeadZone || + Input.GetAxis("RVertical") > rDeadZone || + Input.GetAxis("RVertical") < -rDeadZone) + { + rightStickVector = new Vector2(Input.GetAxis("RHorizontal"), Input.GetAxis("RVertical")); + rightStickIntensity = rightStickVector.magnitude; + } + else + { + rightStickIntensity = 0.0f; + rightStickVector = Vector2.zero; + } + } +} diff --git a/Assets/Resources/Scripts/InputManager.cs.meta b/Assets/Resources/Scripts/InputManager.cs.meta new file mode 100644 index 0000000..18d7e46 --- /dev/null +++ b/Assets/Resources/Scripts/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: df3fc0ea74484414d8eab988c8ea33f6 +timeCreated: 1454122161 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Scripts/PlayerCharacter.cs b/Assets/Resources/Scripts/PlayerCharacter.cs index 683a54e..4e613ea 100644 --- a/Assets/Resources/Scripts/PlayerCharacter.cs +++ b/Assets/Resources/Scripts/PlayerCharacter.cs @@ -1,15 +1,62 @@ using UnityEngine; using System.Collections; +using GameUtils; -public class PlayerCharacter : MonoBehaviour { +public class PlayerCharacter : Controller, ISceneObject { - // Use this for initialization - void Start () { - - } - - // Update is called once per frame - void Update () { - - } + // TPC-Specific Variables + //private bool onGround, canJump, wallDetected; // Other bools should be setup for the different input states (charging, jumping, etc.) + private Rigidbody2D playerRB; + private float distanceToWall; + private RaycastHit wallHit; + //private Collider playerCollider; + private Vector2 joystickMovement, jumpMovement; + + // TPC Editor Variables + public float surfaceNormalAngleThreshold, jumpMagnitude, chargeSpeedModifier, wallRayCastDistance; + + public void Initialize() + { + // Put initialization code here. + movementVector = GameManager.iManager.movementVector; // Shorthand for the InputManager's movement vector. + movementIntensity = GameManager.iManager.movementIntensity; + gameInputMap = GameManager.iManager.gameInputMap; + onGround = false; + canJump = true; + wallDetected = false; + playerRB = gameObject.GetComponent(); + mainCamera = Camera.main; + distanceToWall = wallRayCastDistance; + wallHit = new RaycastHit(); + joystickMovement = Vector2.zero; + jumpMovement = Vector2.zero; + } + + public void ObjectUpdate() + { + print(onGround); + movementVector = GameManager.iManager.movementVector; // Shorthand for the InputManager's movement vector. + movementIntensity = GameManager.iManager.movementIntensity; + + // Put update code here. + if(movementIntensity > 0.0f) + { + print("Attempting to move: " + movementVector); + joystickMovement = new Vector2(movementVector.x, 0.0f) * movementIntensity * movementSpeed; + } + else + { + joystickMovement = Vector2.zero; + } + if(onGround && gameInputMap[GameInput.JUMP]) + { + print("JUUUUUUUUUUUUUUUUUUUUUUMP"); + jumpMovement = transform.up * jumpMagnitude; + } + else + { + jumpMovement = Vector2.zero; + } + playerRB.velocity = joystickMovement + jumpMovement; + } } diff --git a/Assets/Resources/Scripts/Utilities.cs b/Assets/Resources/Scripts/Utilities.cs index a29fcc0..8250fab 100644 --- a/Assets/Resources/Scripts/Utilities.cs +++ b/Assets/Resources/Scripts/Utilities.cs @@ -1,18 +1,52 @@ using UnityEngine; using System.Collections; +using System; -namespace Game_Utils +/// +/// This will store away all of our utility functions during this little game jam of mine. +/// +namespace GameUtils { + /// + /// Collision point class containing relevant collision data: point(world space), contact normal, intensity (how hard?) + /// + public class CollisionPoint : IComparable + { + public Vector3 point, normal; + public float intensity; + + public int CompareTo(CollisionPoint other) + { + // Sort by whichever contact normal is closest to pointing straight up. + return Vector3.Angle(normal, Vector3.up).CompareTo(Vector3.Angle(other.normal, Vector3.up)); + } + } + public interface ISceneObject { - // Called by the GameBrain on scene switch. - void Initialize(); - // Called by the GameBrain's Update function. void ObjectUpdate(); + void Initialize(); } + + public enum GameInput + { + JUMP // Add more as needed + } + public static class Utilities { + public static Vector2 Vec2(Vector3 input) + { + return new Vector2(input.x, input.y); + } + } + + // Game State Enumerator + public enum GameState + { + TITLE, // index 0 + MAINMENU // index 1 + // ... this goes on to define levels, most useful if kept in the same loading order that is to be used during build. } } - diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index db2598e05c5895fae56bdc647bfda2a1f037b74d..5a2759bd0712b81c7640fa16c224d2df7b4638a1 100644 GIT binary patch delta 423 zcmbQBJ;6|tfq|8Yfk9#d0|Ns;1A_pNVqh@UGuAWQDEWegn}dOY7bw8X@c;j2LDtV) zlNDH58Koz)3PiJV1I2?T?-5d+>?XhmGJ}D6a-={wDNlCa8TR{>#0mdPsxqQ!-Q zLJ>*%6~<-;&iQ#IMfo{7sYUUQliv#~PRrVqcJm_{ zCOe3DNQhvyJjiMC2Vn(9)5(G&>Nu46K$Mt(l*mb8H6^4dGd(@EsCcp)3fy^wBp_4ZVut