Created
June 11, 2021 21:19
-
-
Save kurtdekker/8055d18ee64877e4ceca78305e7f15c9 to your computer and use it in GitHub Desktop.
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
using UnityEngine; | |
public class Ballistic : MonoBehaviour | |
{ | |
public Vector3 velocity; | |
void Update () | |
{ | |
velocity += Physics.gravity * Time.deltaTime; | |
transform.position += velocity * Time.deltaTime; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is useful in lieu of a Rigidbody to move stuff around.
Do NOT use this if you have a Rigidbody already on your item, unless it is set to IsKinematic.
This obviously does not know anything about collisions.
You can replace the Physics.gravity term with a function of your liking, such as one to always accelerate towards a particular point in space.