Created
September 7, 2019 00:45
-
-
Save kleberandrade/7c274068ae80e0e17b3589124c925632 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Drawbridge : MonoBehaviour | |
{ | |
public float[] m_Targets = { 90.0f, 0.0f }; | |
private int m_Index = 0; | |
private HingeJoint m_Joint; | |
private void Awake() | |
{ | |
m_Joint = GetComponent<HingeJoint>(); | |
} | |
private void Update() | |
{ | |
if (Input.GetButtonDown("Fire1")) | |
{ | |
JointSpring spring = m_Joint.spring; | |
m_Index = ++m_Index % m_Targets.Length; | |
spring.targetPosition = m_Targets[m_Index]; | |
m_Joint.spring = spring; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment