forked from dr-jam/GameplayProgramming
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add weili branch, balckhole basic setting
- Loading branch information
1 parent
4c1a356
commit af7d2ce
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Projects/Factory/Assets/FactoryGroup0/Scripts/BlackHoleMotion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class BlackHoleMotion : MonoBehaviour | ||
{ | ||
// Start is called before the first frame update | ||
private Rigidbody rd; | ||
private Transform tf; | ||
[SerializeField] | ||
private float FloatStrenght =1; | ||
[SerializeField] | ||
private float LifeTime = 5.0f; | ||
private float timeCounter; | ||
void Start() | ||
{ | ||
timeCounter = 0.0f; | ||
rd = this.gameObject.GetComponent<Rigidbody>(); | ||
tf = this.gameObject.GetComponent<Transform>(); | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
if(timeCounter <= LifeTime) | ||
{ | ||
//does nothing | ||
} | ||
else | ||
{ | ||
if (timeCounter >= 1.5f *LifeTime) | ||
{ | ||
Destroy(this.gameObject); | ||
} | ||
else | ||
{ | ||
var x = 2 / LifeTime * Time.deltaTime; | ||
tf.localScale -= new Vector3(x, x, x); | ||
FloatStrenght -= x; | ||
} | ||
} | ||
rd.AddForce(-1 * rd.mass * Physics.gravity / 2 * FloatStrenght); | ||
timeCounter += Time.deltaTime; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Projects/Factory/Assets/FactoryGroup0/Scripts/BlackHoleMotion.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
m_EditorVersion: 2019.3.0b5 | ||
m_EditorVersionWithRevision: 2019.3.0b5 (13eef430e0c9) | ||
m_EditorVersion: 2019.3.0b4 | ||
m_EditorVersionWithRevision: 2019.3.0b4 (3271e9fc5036) |