-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrone_Movement.cs
94 lines (82 loc) · 2.57 KB
/
Drone_Movement.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Drone_Movement : MonoBehaviour
{
// Declare Flight Controller Variables
public float forwardSpeed = 25f, strafeSpeed = 7.5f, hoverSpeed = 5f;
private float activeForwardSpeed, activeStrafeSpeed, activeHoverSpeed;
// Start is called before the first frame update
void Start()
{
print("Drone Simualtion ");
}
public void Forward()
{
//Debug.Log("Forward Function Called");
transform.position += transform.forward * Time.deltaTime * forwardSpeed;
}
public void Backward()
{
//Debug.Log("Backward Function Called");
transform.position += transform.forward * Time.deltaTime * -forwardSpeed;
}
public void Right()
{
//Debug.Log("Right Function Called");
transform.position += transform.right * Time.deltaTime * strafeSpeed;
}
public void Left()
{
//Debug.Log("Left Function Called");
transform.position += transform.right * Time.deltaTime * -strafeSpeed;
}
public void Up()
{
//Debug.Log("Up Function Called");
transform.position += transform.up * Time.deltaTime * hoverSpeed;
}
public void Down()
{
//Debug.Log("Down Function Called");
transform.position += transform.up * Time.deltaTime * -hoverSpeed;
}
// Update is called once per frame
void Update()
{
//activeForwardSpeed = Input.GetAxisRaw("Vertical") * forwardSpeed;
//activeStrafeSpeed = Input.GetAxisRaw("Horizontal") * strafeSpeed;
//activeHoverSpeed = Input.GetAxisRaw("Hover") * hoverSpeed;
//transform.position += transform.forward * activeForwardSpeed * Time.deltaTime;
if (Input.GetKey(KeyCode.W))
{
//Debug.Log("Pressed w ");
Forward();
}
else if (Input.GetKey(KeyCode.S))
{
//Debug.Log("Pressed s ");
Backward();
}
else if (Input.GetKey(KeyCode.A))
{
//Debug.Log("Pressed a ");
Left();
}
else if (Input.GetKey(KeyCode.D))
{
//Debug.Log("Pressed d ");
Right();
}
else if (Input.GetKey(KeyCode.Space))
{
//Debug.Log("Pressed space ");
Up();
}
else if (Input.GetKey(KeyCode.LeftAlt))
{
//Debug.Log("Pressed left alt ");
Down();
}
}
}