-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPulleyMass.cs
63 lines (50 loc) · 1.38 KB
/
PulleyMass.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//There will only be 1 mass in the scene
public class PulleyMass : MonoBehaviour{
int numPulleysAttached; //each pulley attached corresponds to 2 support ropes
bool supportRopeAttached = false; //whether a support rope is attached directly to the mass
float weight = 10; //default it to 10N; //the weight of the attached mass
public int GetNumPulleysAttached()
{
return numPulleysAttached;
}
public bool GetSupportRopeAttached()
{
return supportRopeAttached;
}
/// <summary>
/// Moves the mass along the given vector
/// </summary>
/// <param name="displacement"></param>
public void MoveMass(Vector3 displacement)
{
Vector3 newPosition = transform.position + displacement;
transform.position = newPosition;
}
public float GetWeight()
{
return weight;
}
public void SetWeight(float w)
{
weight = w;
}
public void AddSupportRope()
{
supportRopeAttached = true;
}
public void RemoveSupportRope()
{
supportRopeAttached = false;
}
public void AddPulleyToMass()
{
numPulleysAttached++;
}
public void RemovePulleyFromMass()
{
numPulleysAttached--;
}
}