-
Notifications
You must be signed in to change notification settings - Fork 2
/
Pulley.cs
61 lines (49 loc) · 1.54 KB
/
Pulley.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Pulley class contains the properties of the pulley
public class Pulley : MonoBehaviour{
float tensionForce; //the tension in the rope around the pulley
float supportForce; //the single force on the support rail
public bool fixedPulley; //if the pulley is a fixed pulley then = true else it is a moveable pulley
//if a pulley is fixed then it isn't attached to the mass, if it is moveable then it is attached
private void Start()
{
tensionForce = 0;
supportForce = 0;
}
//Getters and setters for the tension force, support force and whether it is a fixed pulley or not
public void ChangeTensionForce(float force)
{
tensionForce = force;
}
public float GetTensionForce()
{
return tensionForce;
}
public void ChangeSupportForce(float force)
{
supportForce = force;
}
public float GetSupportForce()
{
return supportForce;
}
public void SetToFixedPulley()
{
fixedPulley = true;
}
public void SetToSupportPulley()
{
fixedPulley = false;
}
/// <summary>
/// Moves the pulley along the given vector
/// </summary>
/// <param name="displacement"></param>
public void MovePulley(Vector3 displacement)
{
Vector3 newPosition = transform.position + displacement;
transform.position = newPosition;
}
}