Beispiel #1
0
 private void Rewind()
 {
     if (objectPositions.Count > 0)
     {
         ThrowableTimePosition currentPos = objectPositions[objectPositions.Count - 1];
         transform.position = currentPos.position;
         // Set object new movement state at past position
         throwableObj.moveAmount = currentPos.moveAmount;
         // Remove the position from the stored list
         objectPositions.RemoveAt(objectPositions.Count - 1);
     }
 }
Beispiel #2
0
    /// <summary>
    /// Adds a new throwable position to the position list.
    /// </summary>
    public void AddPosition(Throwable obj, List <ThrowableTimePosition> posArray)
    {
        // Making new position to store in list
        ThrowableTimePosition pos = new ThrowableTimePosition();

        pos.position    = obj.transform.position;
        pos.time        = Time.time;
        pos.isBeingHeld = obj.isBeingHeld;
        pos.moveAmount  = obj.moveAmount;

        posArray.Add(pos);

        // Continuously removing all positions outside time threshold
        posArray.RemoveAll(x => x.time <= (Time.time - rewindSeconds));
    }