Browse Source

added gliding

master
Josh 2 years ago
parent
commit
c841970cc5
  1. 22
      unity/Assets/Game.cs
  2. 11
      unity/Assets/Game.cs.meta
  3. 15
      unity/Assets/Scripts/DragonMovement.cs

22
unity/Assets/Game.cs

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Game : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.R))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
}

11
unity/Assets/Game.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ae6e336b628b3624eab0909498a43f51
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

15
unity/Assets/Scripts/DragonMovement.cs

@ -92,7 +92,16 @@ public class DragonMovement : MonoBehaviour
}
if (_stunTime > 0f)
{
_rigidbody.AddForce(new Vector2(0f, FlapForce * -.5f));
_rigidbody.AddForce(new Vector2(FlapForce * -.05f, FlapForce * -.05f));
transform.Rotate(Vector3.forward, Time.deltaTime * 1000f);
if (_flapTime < 0f)
{
_flapTime = 0f;
}
}
else
{
transform.rotation = Quaternion.identity;
}
_flapTime -= Time.deltaTime;
_stunTime -= Time.deltaTime;
@ -132,7 +141,9 @@ public class DragonMovement : MonoBehaviour
horizontalSpeed = -2f;
}
transform.position = new Vector3(transform.position.x + horizontalSpeed, transform.position.y+ verticalSpeed, transform.position.z);
float x = transform.position.x + horizontalSpeed;
x = Mathf.Max(x, 32);
transform.position = new Vector3(x, transform.position.y+ verticalSpeed, transform.position.z);
}
}

Loading…
Cancel
Save