Add working ropes

This commit is contained in:
Patrice Vignola 2016-01-30 16:52:43 -05:00
parent 1cc4ddc40f
commit 793ad331b8
8 changed files with 9007 additions and 86 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,19 +18,41 @@ public class Character : MonoBehaviour
private float dashRemainingTime = 0f; private float dashRemainingTime = 0f;
private bool isDashing = false; private bool isDashing = false;
private int playerId;
private SelectorWithBolts selector;
private Vector3 dashForward;
public int PlayerID
{
get { return playerId; }
set { playerId = value; }
}
void Awake() void Awake()
{ {
rb = GetComponent<Rigidbody>(); rb = GetComponent<Rigidbody>();
} }
void Start()
{
selector = GameObject.FindObjectOfType<SelectorWithBolts>();
}
void Update() void Update()
{ {
Debug.Log(rb.velocity.magnitude);
if (dashRemainingTime > 0) if (dashRemainingTime > 0)
{ {
dashRemainingTime = Mathf.Clamp(dashRemainingTime - Time.deltaTime, 0f, DashCooldown); dashRemainingTime = Mathf.Clamp(dashRemainingTime - Time.deltaTime, 0f, DashCooldown);
} }
if (!isDashing) if (isDashing)
{
rb.AddForce(dashForward * DashForce, ForceMode.VelocityChange);
}
else
{ {
rb.rotation = Quaternion.RotateTowards(rb.rotation, targetRot, TurnSpeed * Time.deltaTime); rb.rotation = Quaternion.RotateTowards(rb.rotation, targetRot, TurnSpeed * Time.deltaTime);
} }
@ -78,9 +100,9 @@ public class Character : MonoBehaviour
{ {
isDashing = true; isDashing = true;
Vector3 fwd = GetComponent<Transform>().forward; dashForward = GetComponent<Transform>().forward;
rb.velocity = Vector3.zero; rb.velocity = Vector3.zero;
rb.AddForce(fwd * DashForce, ForceMode.Impulse);
animator.SetTrigger("Dash"); animator.SetTrigger("Dash");
yield return new WaitForSeconds(0.9f); yield return new WaitForSeconds(0.9f);

View File

@ -14,6 +14,8 @@ public class CharacterController : MonoBehaviour
InputManager.Instance.PushActiveContext("Normal", (int)playerNumber); InputManager.Instance.PushActiveContext("Normal", (int)playerNumber);
InputManager.Instance.AddCallback((int)playerNumber, HandlePlayerAxis); InputManager.Instance.AddCallback((int)playerNumber, HandlePlayerAxis);
InputManager.Instance.AddCallback((int)playerNumber, HandlePlayerButtons); InputManager.Instance.AddCallback((int)playerNumber, HandlePlayerButtons);
character.PlayerID = (int)playerNumber;
} }
private void HandlePlayerAxis(MappedInput input) private void HandlePlayerAxis(MappedInput input)

View File

@ -0,0 +1,30 @@
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody))]
public class SelectorWithBolts : MonoBehaviour
{
public Transform[] Bolts;
public Transform[] RootCylinders;
private Rigidbody rb;
void Awake()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
for (int i = 0; i < RootCylinders.Length; i++)
{
Vector3 constraintPos = Bolts[i].position;
RootCylinders[i].position = constraintPos;
}
}
public void ApplyForce(int playerID, Vector3 force)
{
rb.AddForceAtPosition(force, Bolts[playerID].position);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a45987b669b860c4ebaf9d773918cd04
timeCreated: 1454177626
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,12 +4,12 @@
PhysicsManager: PhysicsManager:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Gravity: {x: 0, y: -9.81, z: 0} m_Gravity: {x: 0, y: -9.81000042, z: 0}
m_DefaultMaterial: {fileID: 0} m_DefaultMaterial: {fileID: 0}
m_BounceThreshold: 2 m_BounceThreshold: 2
m_SleepThreshold: 0.005 m_SleepThreshold: .00499999989
m_DefaultContactOffset: 0.01 m_DefaultContactOffset: .00999999978
m_SolverIterationCount: 6 m_SolverIterationCount: 6
m_QueriesHitTriggers: 1 m_QueriesHitTriggers: 1
m_EnableAdaptiveForce: 0 m_EnableAdaptiveForce: 0
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8fffffffefffffffaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

View File

@ -13,9 +13,9 @@ TagManager:
- UI - UI
- -
- -
- - Cylinder
- - Character
- - Ouija
- -
- -
- -