You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
742 B
29 lines
742 B
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class ResetSample : MonoBehaviour |
|
{ |
|
public Transform[] Objects; |
|
private List<Vector3> PosList = new(); |
|
private List<Quaternion> RotList = new(); |
|
void Start() |
|
{ |
|
foreach (var obj in Objects) |
|
{ |
|
PosList.Add(obj.position); |
|
RotList.Add(obj.rotation); |
|
} |
|
} |
|
|
|
public void Reset() |
|
{ |
|
for(int i = 0; i < PosList.Count; ++i) |
|
{ |
|
Objects[i].GetComponent<Rigidbody>().velocity = Vector3.zero; |
|
Objects[i].GetComponent<Rigidbody>().angularVelocity = Vector3.zero; |
|
Objects[i].SetPositionAndRotation(PosList[i], RotList[i]); |
|
} |
|
} |
|
|
|
}
|
|
|