-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoundShipController.cs
More file actions
62 lines (57 loc) · 1.55 KB
/
Copy pathRoundShipController.cs
File metadata and controls
62 lines (57 loc) · 1.55 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
///
/// ROUND SHIP LEVEL CONTROLLER
///
/// This script will make the hamster wheel hub level
/// rotate using A and D while the player stays
/// in place. Nothing complicated.
///
/// In addition, it will rotate the background at a slow
/// speed.
///
///
/// </summary>
public class RoundShipController : MonoBehaviour
{
//variables
//
public float speed;
//level object is the round ship hub
GameObject level;
//background object is the space background object
GameObject background;
//methods
//
void Update()
{
LevelControl();
BackgroundRotate();
}
//at frame 1, the bg and level objects are found
void Start()
{
level = GameObject.FindGameObjectWithTag("Level");
background = GameObject.FindGameObjectWithTag("Background");
}
//Input Axis changes rotate the level
void LevelControl()
{
//both of these if statements will simply rotate a parent object (the hub level)
if (Input.GetAxis("Horizontal")>0.5)
{
level.transform.Rotate(new Vector3(0f, 0f, -speed));
}
else if (Input.GetAxis("Horizontal")<-0.5)
{
level.transform.Rotate(new Vector3(0f, 0f, speed));
}
}
//Ambient background rotation due to moving ship :)
void BackgroundRotate()
{
background.transform.Rotate(new Vector3(0f, 0f, 0.01f));
}
}