Skip to content

Commit 41fe05b

Browse files
committed
Magnus Effect implementation
1 parent 3f04725 commit 41fe05b

9 files changed

+79
-5
lines changed

Assets/InitialVelocity.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class InitialVelocity : MonoBehaviour {
6+
7+
public Vector3 initialVelocity;
8+
public Vector3 initialW;
9+
10+
private Rigidbody rb;
11+
12+
void Start ()
13+
{
14+
rb = GetComponent<Rigidbody>();
15+
rb.velocity = initialVelocity;
16+
rb.angularVelocity = initialW;
17+
}
18+
19+
}

Assets/InitialVelocity.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/MagnusEffect.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class MagnusEffect : MonoBehaviour {
6+
7+
public float magnusConstant = 1.0f;
8+
9+
private InitialVelocity initial;
10+
11+
private Rigidbody rb;
12+
13+
void Start ()
14+
{
15+
rb = GetComponent<Rigidbody>();
16+
initial = GetComponent<InitialVelocity>();
17+
}
18+
19+
// Update is called once per frame
20+
void Update ()
21+
{
22+
rb.AddForce(magnusConstant * Vector3.Cross(rb.angularVelocity, rb.velocity));
23+
24+
}
25+
}

Assets/MagnusEffect.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Torque.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Torque : MonoBehaviour {
88
public Vector3 torqueToAdd = new Vector3();
99
public float torqueTime;
1010
private Rigidbody rb;
11-
11+
1212
void Start ()
1313
{
1414
rb = GetComponent<Rigidbody>();

Assets/Test.physicMaterial

4.05 KB
Binary file not shown.

Assets/_Scenes/etc.meta renamed to Assets/Test.physicMaterial.meta

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/_Scenes/03 Magnus Effect.unity

18.6 KB
Binary file not shown.

Assets/_Scenes/03 Magnus Effect.unity.meta

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)