private void Start() { // Get the action that will be fired when the 'Interact' key is pressed. _input = GetComponent <UnityEngine.InputSystem.PlayerInput>(); _interactAction = _input.currentActionMap.FindAction("Interact"); // Subscribe to the event. _interactAction.performed += OnInteract; }
private void Start() { _rigidbody2D = GetComponent <Rigidbody2D>(); // Get the action that will be fired when the 'move' keys are pressed. _input = GetComponent <UnityEngine.InputSystem.PlayerInput>(); _moveAction = _input.currentActionMap.FindAction("Move"); // Subscribe to the event. _moveAction.performed += context => playerMoveDirection.Value = context.ReadValue <Vector2>(); }
public void InitiateInputSystem() { playerInput = this.GetComponent <UnityEngine.InputSystem.PlayerInput>(); if (Application.isMobilePlatform) { Debug.Log("Is ported to mobile"); BeginMobileInputSystem(); } else { Debug.Log("Is ported to desktop"); BeginDesktopInputSystem(); } }
//public PlayerCharacter(Damageable dmg, Animator ani, SpriteRenderer sr, Rigidbody2D rb, BoxCollider2D bc, float baseMovementSpeed ) // :base(dmg, ani, sr, rb, bc, baseMovementSpeed) //{ //} // According to this https://forum.unity.com/threads/onenable-before-awake.361429/ awake, onenable, start, ect are by script // and do not have call all of the scripts awake, then OnEnable, ect. // According to this https://answers.unity.com/questions/13304/how-to-set-starting-order-of-scripts.html // and actual attempts the way to set script execution is from within the unity gui // Go To Edit -> Prokect Settings -> Script Execution Order and add scripts there in the order they should // be run. void Awake() { //healthDetailed = new HealthPipModel(startingHealth, 1); //health = healthDetailed; //healthDetailed.RealHp = 3; //healthDetailed.TempHp = 7; if (rigidbody2D == null) { rigidbody2D = GetComponent <Rigidbody2D>(); } if (spriteRenderer == null) { spriteRenderer = GetComponent <SpriteRenderer>(); } if (animator == null) { animator = GetComponent <Animator>(); } if (boxCollider == null) { boxCollider = GetComponent <BoxCollider2D>(); } if (damageable == null) { damageable = GetComponent <DamageablePlayer>(); } if (GameHandler == null) { GameHandler = transform.Find("GameHandler")?.GetComponent <GameHandler>(); } if (cameraFollowTarget == null) { cameraFollowTarget = transform.Find("CameraFollowTarget")?.GetComponent <Transform>(); } if (PlayerInput == null) { PlayerInput = new UnityEngine.InputSystem.PlayerInput(); } if (timeBetweenVisualHitFlashes == 0) { timeBetweenVisualHitFlashes = .25f; } if (InteractObjRenderer == null) { foreach (Transform child in transform) { if (child.name == "InteractFlag") { InteractObjRenderer = child.GetComponent <SpriteRenderer>(); } } if (InteractObjRenderer == null) { InteractObjRenderer = transform.Find("InteractFlag")?.GetComponent <SpriteRenderer>(); } } // Get PipModel for legs and get the associated LegPipUp values if (baseMovementSpeed == 0) { baseMovementSpeed = 10f; } if (jumpForce == 0) { jumpForce = 2; } if (jumpTime == 0) { jumpTime = 0.05f; } // Basic all in one shader if added as the material // Look to AllIn1SpriteShader.shader file for the names // for invincibility // FLICKER_ON, percent 0.25 | frequent 1 //Material mat = GetComponent<Renderer>().material; //mat.SetFloat("_Glow", 10f); //mat.EnableKeyword("GLOW_ON"); }