Created
September 7, 2024 16:05
-
-
Save IvanEnginer/775e70bb5377219da993df7e3a2387b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Bird : MonoBehaviour | |
{ | |
[SerializeField] private Vector3 _jumpForse; | |
[SerializeField] private Vector3 _shiftForse; | |
[SerializeField] private int _shiftScoreMultiplication; | |
[SerializeField] private int _baseAward; | |
private Rigidbody _rigidbody; | |
public int JumpCount { get; private set; } | |
private void Awake() | |
{ | |
_rigidbody = GetComponent<Rigidbody>(); | |
} | |
private void Update() | |
{ | |
if (Input.GetKeyUp(KeyCode.Space)) | |
{ | |
_rigidbody.AddForce(_jumpForse, ForceMode.Impulse); | |
JumpCount += _baseAward; | |
} | |
if(Input.GetKeyUp(KeyCode.A)) | |
{ | |
_rigidbody.AddForce(-_shiftForse, ForceMode.Impulse); | |
JumpCount += _baseAward * _shiftScoreMultiplication; | |
} | |
if (Input.GetKeyUp(KeyCode.D)) | |
{ | |
_rigidbody.AddForce(_shiftForse, ForceMode.Impulse); | |
JumpCount += _baseAward * _shiftScoreMultiplication; | |
} | |
} | |
public void ResetJumpCounter() | |
{ | |
JumpCount = 0; | |
} | |
public void ResetVelocity() | |
{ | |
_rigidbody.velocity = new Vector3(0, 0, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment