-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathSpringNode.cs
More file actions
56 lines (38 loc) · 1.08 KB
/
SpringNode.cs
File metadata and controls
56 lines (38 loc) · 1.08 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//This node can be connected to multiple springs
public abstract class SpringNode
{
//Is this node connected to a wall?
public bool isFixed;
//The total force on this node from the springs attached to it
//public Vector2 force;
//Gravity
//private readonly Vector2 g = new(0f, -9.81f);
public SpringNode(bool isFixed = false)
{
this.isFixed = isFixed;
}
//public void UpdateNodeState(float dt)
//{
// if (isFixed)
// {
// return;
// }
// float m = 1f;
// //Add gravity
// Vector2 F_gravity = m * g;
// force += F_gravity;
// //Calculate the acceleration on this node
// //F = m*a -> a = F/m
// Vector2 a = force / m;
// //Move the simulation forward one step
// this.vel += dt * a;
// this.pos += dt * this.vel;
// //Add some damping
// //this.vel *= 0.99f;
// //Reset F
// force = Vector2.zero;
//}
}