- Home /
Saving coordinates and transferring them to the second object
hi i have a question. there is an object to which the rotation script is attached, how to make it so that when this object is destroyed, the coordinates at which it stopped are saved, and these coordinates are transferred to the second object, which will appear after the destruction of the first
rotation script:
public float tilt;
void Update()
{
transform.Rotate(Vector3.back * tilt);
}
Answer by DenisIsDenis · Jun 06, 2021 at 03:12 AM
You can store the position of the object before destroying in the Vector3 variable, and then assign this value to the position of the new object. For example (incomplete code):
Vector3 position; // position saveing variable
void ExampleDestroy()
{
position = objectToDestroy.transform.position;
Destroy(objectToDestroy);
}
void ExampleInstantiate()
{
newObject = Instantiate(objectPrefab);
newObject.transform.position = position;
}
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Unit rotation fails consistently on all slerp rotations after the first? 0 Answers
How do i rotate an object "Once" 1 Answer
Making transform child rotation global 1 Answer
How can I modify this rotation code to change how far the object rotates? 0 Answers