Skip to content

Instantly share code, notes, and snippets.

View cdfisher's full-sized avatar

Chris cdfisher

  • Boston
View GitHub Profile
@cdfisher
cdfisher / Spring.cs
Last active November 18, 2025 22:29
Spring animation for Unity
using UnityEngine;
public class Spring : MonoBehaviour
{
GameObject A, B;
Vector3 posA, posB;
Vector3 FS, FD, Gravity, NetForce, Accel, V;
int Mass = 1;
int KS = 5;
int LR = 2;
@cdfisher
cdfisher / InvKinematics.cs
Last active November 4, 2025 21:17
Inverse kinematics Unity MonoBehavior for a single joint
using UnityEngine;
using System;
public class InvKinematics : MonoBehaviour
{
public double about_x; // x to rotate about
public double about_y; // y to rotate about
public double x_init; // initial x
public double y_init; // initial y
public double x_prime; // final x
using UnityEngine;
public class Orbiter : MonoBehaviour
{
public GameObject Sun;
public GameObject Earth;
public GameObject Moon;
private Vector3 sunPos;
private Vector3 earthPos;