# How do I calculate a translation without a game object???

Hello,
I have ran into a problem with creating and destroying a gameobject within the same frame, even when trying to destroy its reference (through the same variable used TO create the gameobject). It seems like I need the creation of a new gameobject in order to be able to calculate the translation from a 3D Vector to the ‘translated’ 3D point in world space, but after calculating the new 3D point, I would like to have the object destroyed in the same frame. How would I do this?.. or is there another way of getting a newly ‘translated’ point?

Thank you,
Michael S. Lowe

if this is not in your Update function, I would try an IEnumerator and use the waitforendofframe and place the destroy in there. Or you can calculate the translation mathematically without creating a gameobject, but that is a different story on it’s own.

What is it that you’re trying to calculate in the first place?

I am trying to create a ‘catastrophic effect’ of multiple rooms creating multiple walls, and multiple walls creating multiple objects, and multiple objects creating multiple ‘sub items’ etc. and each having its own script, but the creation and destroying of objects not ‘calculating’ within the same frame before rendering has always been a ‘problem’ that later leads to confusion for me between scripts in game development.

It’s fairly straightforward. I’ll use a Transform’s values here, assuming you have equivalent variables that you’re working with. Just replace transform.localPosition, etc with your equivalent variables.

``````Vector3 TranslatePoint(Vector3 point) {
//scale first
point = Vector3.Scale(transform.localScale, point);
//rotate
point = transform.localRotation * point;
//position
point += transform.localPosition;
return point;
}
``````

It’s possible to create a Matrix4x4 represent those three operations that would do this slightly more efficiently, but if you’re changing the frame every operation, it probably wouldn’t save much time.