Skip to content

Instantly share code, notes, and snippets.

@IvanEnginer
Created September 7, 2024 16:05
Show Gist options
  • Save IvanEnginer/775e70bb5377219da993df7e3a2387b7 to your computer and use it in GitHub Desktop.
Save IvanEnginer/775e70bb5377219da993df7e3a2387b7 to your computer and use it in GitHub Desktop.
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