Skip to content

Instantly share code, notes, and snippets.

View nailuj05's full-sized avatar

Sil3nt nailuj05

View GitHub Profile
@nailuj05
nailuj05 / LineCollider.cs
Created September 9, 2021 21:01
A simple way to add a collider to a Unity LineRenderer, intended for 2D use, can be adapted to 3D aswell!
using UnityEngine;
[RequireComponent(typeof(BoxCollider2D), typeof(LineRenderer))]
public class LineCollider : MonoBehaviour
{
private LineRenderer lineRenderer;
private BoxCollider2D boxCollider;
void Awake()
{
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Created October 24, 2014 07:14
Extension methods for working with Configurable Joints for Unity
using UnityEngine;
public static class ConfigurableJointExtensions
{
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Last active September 9, 2024 17:33
Unity extension methods for computing a ConfigurableJoint.TargetRotation value from a given local or world rotation.
using UnityEngine;
public static class ConfigurableJointExtensions {
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
if (joint.configuredInWorldSpace) {