//vehicle stuff void OnCollisionEnter(Collision other) { if (IsValidVehicle(other.collider.gameObject)) { Rideable newVehicle = other.collider.gameObject.GetComponentInParent <Rideable> (); newVehicle.Mount(gameObject); EnterVehicle(newVehicle); } }
protected virtual void EnterVehicle(Rideable newVehicle) { inVehicle = true; if (navAgent != null) { navAgent.enabled = false; } }
protected override bool IsValidVehicle(GameObject vehicle) { if (vehicle == null) { return(false); } Rideable otherRideable = vehicle.GetComponentInParent <Rideable> (); return(otherRideable != null && otherRideable.canBeMounted && otherRideable.isEnemyMountable && (!otherRideable.driver || otherRideable.tag == "Enemy")); }
/// <summary> /// Adds the colliders to the rideable ability. /// </summary> /// <param name="rideable">The ability to add the colliders to.</param> /// <param name="parent">The parent of the rideable ability.</param> private void AddDismountColliders(Rideable rideableAbility, GameObject parent) { // Position the collider under the Colliders GameObject if it exists. Transform collidersTransform; if ((collidersTransform = parent.transform.Find("Colliders"))) { parent = collidersTransform.gameObject; } rideableAbility.LeftDismountCollider = CreateCollider(parent, "Left Dismount Collider", new Vector3(-0.9f, 1, 0)); rideableAbility.RightDismountCollider = CreateCollider(parent, "Right Dismount Collider", new Vector3(0.9f, 1, 0)); }
/// <summary> /// Removes the collider from the rideable ability. /// </summary> /// <param name="rideableAbility">The ability to remove the colliders from.</param> /// <param name="parent">The parent of the rideable ability.</param> private void RemoveDismountColliders(Rideable rideableAbility, GameObject parent) { if (rideableAbility.LeftDismountCollider != null) { UnityEngine.Object.DestroyImmediate(rideableAbility.LeftDismountCollider.gameObject, true); rideableAbility.LeftDismountCollider = null; } if (rideableAbility.RightDismountCollider != null) { UnityEngine.Object.DestroyImmediate(rideableAbility.RightDismountCollider.gameObject, true); rideableAbility.RightDismountCollider = null; } }
void Awake() { lrend = GetComponent <LineRenderer> (); lrend.enabled = false; seat = transform.Find("Seat"); col = GetComponent <BoxCollider> (); col.enabled = false; rideable = GetComponentInParent <Rideable> (); wasControllable = rideable.controllable; wasDismountable = rideable.dismountable; }
public void PrepareForVehicle(Rideable newVehicle) { health.ResetColor(); rb.interpolation = RigidbodyInterpolation.None; rb.constraints = RigidbodyConstraints.FreezeRotation; currentVehicle = newVehicle; state = MovementState.Grounded; SwipeManager.instance.EndSwipe(); curPickingupTimers.Clear(); }
public void ExitVehicle() { if (rb != null) { rb.interpolation = RigidbodyInterpolation.Extrapolate; rb.constraints = RigidbodyConstraints.FreezeRotation; rb.velocity = currentVehicle.GetComponent <Rigidbody> ().velocity; } state = MovementState.Jumping; currentVehicle.Dismount(); currentVehicle = null; shooting.canRotateParent = true; shooting.gameObject.SetActive(true); health.ResetColor(); }
void OnCollisionEnter(Collision other) { if (other.collider.tag == "Vehicle") { Rideable newVehicle = other.gameObject.GetComponentInParent <Rideable> (); if (newVehicle != null && newVehicle.canBeMounted) { EnterVehicle(newVehicle); //enter vehicle when you hit something tagged with vehicle } } else { //changes states when hit if (state == MovementState.Jumping) { shooting.canRotateParent = false; state = MovementState.Tumbling; } } }
void OnTriggerExit(Collider coll) { bool player = false; if (coll.tag == "Player") { player = true; } else if (coll.GetComponentInParent <Rideable> ()) { // rideable object entered zone Rideable rideable = coll.GetComponentInParent <Rideable> (); if (rideable.driver) { player = true; } } if (player) { targetColor = originalColor; } }
protected override void EnterVehicle(Rideable newVehicle) { base.EnterVehicle(newVehicle); }
public void UnRide() { transform.SetParent(null); currentRide = null; charController.enabled = true; }
public void Ride(Transform rideable) { transform.SetParent(rideable); currentRide = rideable.GetComponent <Rideable>(); charController.enabled = false; }
void EnterVehicle(Rideable newVehicle) { PrepareForVehicle(newVehicle); currentVehicle.Mount(gameObject); }