mirror of
https://github.com/ConjureETS/OuijaMTLGJ2016.git
synced 2026-03-24 02:01:06 +00:00
Add working ropes
This commit is contained in:
parent
1cc4ddc40f
commit
793ad331b8
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -18,19 +18,41 @@ public class Character : MonoBehaviour
|
||||
private float dashRemainingTime = 0f;
|
||||
private bool isDashing = false;
|
||||
|
||||
private int playerId;
|
||||
private SelectorWithBolts selector;
|
||||
|
||||
private Vector3 dashForward;
|
||||
|
||||
public int PlayerID
|
||||
{
|
||||
get { return playerId; }
|
||||
set { playerId = value; }
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
selector = GameObject.FindObjectOfType<SelectorWithBolts>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Debug.Log(rb.velocity.magnitude);
|
||||
|
||||
if (dashRemainingTime > 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -78,9 +100,9 @@ public class Character : MonoBehaviour
|
||||
{
|
||||
isDashing = true;
|
||||
|
||||
Vector3 fwd = GetComponent<Transform>().forward;
|
||||
dashForward = GetComponent<Transform>().forward;
|
||||
rb.velocity = Vector3.zero;
|
||||
rb.AddForce(fwd * DashForce, ForceMode.Impulse);
|
||||
|
||||
animator.SetTrigger("Dash");
|
||||
|
||||
yield return new WaitForSeconds(0.9f);
|
||||
|
||||
@ -14,6 +14,8 @@ public class CharacterController : MonoBehaviour
|
||||
InputManager.Instance.PushActiveContext("Normal", (int)playerNumber);
|
||||
InputManager.Instance.AddCallback((int)playerNumber, HandlePlayerAxis);
|
||||
InputManager.Instance.AddCallback((int)playerNumber, HandlePlayerButtons);
|
||||
|
||||
character.PlayerID = (int)playerNumber;
|
||||
}
|
||||
|
||||
private void HandlePlayerAxis(MappedInput input)
|
||||
|
||||
30
Assets/scripts/SelectorWithBolts.cs
Normal file
30
Assets/scripts/SelectorWithBolts.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
12
Assets/scripts/SelectorWithBolts.cs.meta
Normal file
12
Assets/scripts/SelectorWithBolts.cs.meta
Normal 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:
|
||||
@ -4,12 +4,12 @@
|
||||
PhysicsManager:
|
||||
m_ObjectHideFlags: 0
|
||||
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_BounceThreshold: 2
|
||||
m_SleepThreshold: 0.005
|
||||
m_DefaultContactOffset: 0.01
|
||||
m_SleepThreshold: .00499999989
|
||||
m_DefaultContactOffset: .00999999978
|
||||
m_SolverIterationCount: 6
|
||||
m_QueriesHitTriggers: 1
|
||||
m_EnableAdaptiveForce: 0
|
||||
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8fffffffefffffffaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
|
||||
@ -13,9 +13,9 @@ TagManager:
|
||||
- UI
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
- Cylinder
|
||||
- Character
|
||||
- Ouija
|
||||
-
|
||||
-
|
||||
-
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user