Skip to content

Instantly share code, notes, and snippets.

@kurtdekker
Created June 11, 2021 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurtdekker/8055d18ee64877e4ceca78305e7f15c9 to your computer and use it in GitHub Desktop.
Save kurtdekker/8055d18ee64877e4ceca78305e7f15c9 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class Ballistic : MonoBehaviour
{
public Vector3 velocity;
void Update ()
{
velocity += Physics.gravity * Time.deltaTime;
transform.position += velocity * Time.deltaTime;
}
}
@kurtdekker
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment