/// <summary> /// This exists as part of the IKartCollider interface. It is called when a kart collides with this kart. /// </summary> /// <param name="collidingKart">The kart that has collided with this kart.</param> /// <param name="collisionHit">Data for the collision.</param> /// <returns>The velocity of the colliding kart once it has been modified.</returns> public Vector3 ModifyVelocity (IKartInfo collidingKart, RaycastHit collisionHit) { float weightDifference = collidingKart.CurrentStats.weight - m_ModifiedStats.weight; if (weightDifference <= 0f) { Vector3 toCollidingKart = (collidingKart.Position - m_RigidbodyPosition).normalized; return collidingKart.Velocity + toCollidingKart * (kartToKartBump - weightDifference); } return collidingKart.Velocity; }
/// <summary> /// This exists as part of the IKartCollider interface. It is called when a kart collides with this kart. /// </summary> /// <param name="collidingKart">The kart that has collided with this kart.</param> /// <param name="collisionHit">Data for the collision.</param> /// <returns>The velocity of the colliding kart once it has been modified.</returns> public Vector3 ModifyVelocity(IKartInfo collidingKart, RaycastHit collisionHit) { float weightDifference = collidingKart.CurrentStats.weight - m_ModifiedStats.weight; if (weightDifference <= 0f) { Vector3 toCollidingKart = (collidingKart.Position - m_RigidbodyPosition).normalized; return(collidingKart.Velocity + toCollidingKart * (kartToKartBump - weightDifference)); } // Debug.DrawRay(collisionHit.point, collisionHit.normal, Color.cyan); return(collidingKart.Velocity); }
public Vector3 ModifyVelocity(IKartInfo collidingKart, RaycastHit collisionHit) { Vector3 modifiedVelocity = collidingKart.Velocity; if (collidingKart.IsGrounded) { modifiedVelocity = Vector3.ProjectOnPlane(modifiedVelocity, collidingKart.CurrentGroundInfo.normal); } modifiedVelocity -= Vector3.Project(modifiedVelocity, collisionHit.normal) * (1f + bounciness); return(modifiedVelocity); }
void Start() { frontLeftWheel.Setup(); frontRightWheel.Setup(); rearLeftWheel.Setup(); rearRightWheel.Setup(); m_KartMovement = kartMovement as IKartInfo; m_Input = input as IInput; m_DefaultSteeringWheelLocalRotation = steeringWheel.localRotation; m_NormalizedSteeringWheelRotationAxis = steeringWheelRotationAxis.normalized; m_InverseFrontWheelRadius = 1f / frontWheelRadius; m_InverseRearWheelRadius = 1f / rearWheelRadius; }
/// <inheritdoc /> public override void Reposition(Checkpoint lastCheckpoint, IMovable movable, bool isControlled) { IKartInfo kartInfo = movable.GetKartInfo(); if (kartInfo == null) { RepositionComplete(movable, isControlled); return; } Vector3 kartToResetPosition = repositionPoint.ResetPosition - kartInfo.Position; Quaternion kartToResetRotation = repositionPoint.ResetRotation * Quaternion.Inverse(kartInfo.Rotation); movable.ForceMove(kartToResetPosition, kartToResetRotation); RepositionComplete(movable, isControlled); }
void Awake() { m_KartInfo = kartInfo as IKartInfo; m_RandomBuffer = new float[97]; for (var i = 0; i < m_RandomBuffer.Length; i++) { m_RandomBuffer[i] = Random.Range(-1, 1); } intake.Init(); compression.Init(); combustion.Init(); exhaust.Init(); m_Stroke = 0; m_Time = 0; m_SecondsPerSample = 1f / AudioSettings.outputSampleRate; }
public Vector3 ModifyVelocity(IKartInfo collidingKart, RaycastHit collisionHit) { //if the normal of collision points almost straight up or down, don't bounce if (Mathf.Abs(Vector3.Dot(collisionHit.normal, Vector3.up)) > .2f) { return(collidingKart.Velocity); } Vector3 modifiedVelocity = collidingKart.Velocity; if (collidingKart.IsGrounded) { modifiedVelocity = Vector3.ProjectOnPlane(modifiedVelocity, collidingKart.CurrentGroundInfo.normal); } modifiedVelocity -= Vector3.Project(modifiedVelocity, collisionHit.normal) * (1f + bounciness); return(modifiedVelocity); }
void Start() { if (checkpoints.Count == 0) { return; } Object[] allRacerArray = FindObjectsOfType <Object> ().Where(x => x is IRacer).ToArray(); for (int i = 0; i < allRacerArray.Length; i++) { IRacer racer = allRacerArray[i] as IRacer; m_RacerNextCheckpoints.Add(racer, checkpoints[0]); racer.DisableControl(); } m_Input = input as IInput; m_KartMovement = kartMovement as IKartInfo; if (tema == 1) { // mru for (int i = 0; i < questions_mru.Length; i++) { randPreguntas.Add(i); } //randPreguntas.Shuffle(); } if (tema == 2) { // mruv for (int i = 0; i < questions_mruv.Length; i++) { randPreguntas.Add(i); } //randPreguntas.Shuffle(); } }
void Start() { carInfo = ObjectMovable.GetKartInfo(); gearRatio = CreateGearRatio(numGears, ObjectMovable.defaultStats.topSpeed); }
public int framemod = 1; // Number of frames per serial communication to Arduino // Awake is called at initialization void Awake() { // Connect Kart Information m_KartInfo = kartInfo as IKartInfo; }
void Awake() { thread.StartThread(); m_KartInfo = kartInfo as IKartInfo; }
void Awake() { Debug.Log("ArduinoComm is awake."); m_KartMovement = kartMovement as IKartInfo; }