x


Get transform of instantiated Prefab; Help appreciated.

Hi everyone,

I have a small problem I can't seem to deal with. I am trying to destroy a plane/player object and instantiate a dead' camera smoothly looking at the crash site. The problem is that the target of the camera is a prefab (the wreck of the plane) and the camera will look at the prefab position when it was created (0, 0, 0) not where the prefab is actually instantiated.

This is the code to instantiate both the prefab and the camera...

I wonder if placing a camera in the wreck prefab would work? I'll do that just now :)

function Die () {

   var planeWreckClone = Instantiate(planeWreck, transform.position, transform.rotation);
   var deadCamera = Instantiate(deadCamera, transform.position, transform.rotation);

   Destroy(gameObject);
}

Thanks in advance!

more ▼

asked Nov 23 '10 at 09:32 AM

Airship Games gravatar image

Airship Games
257 49 69 86

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I wonder if placing a camera in the wreck prefab would work? I'll do that just now :)

Well, what do you know. It worked :)

phew; artist should not code.

more ▼

answered Nov 23 '10 at 09:35 AM

Airship Games gravatar image

Airship Games
257 49 69 86

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3014
x1682
x1281
x1260
x74

asked: Nov 23 '10 at 09:32 AM

Seen: 1221 times

Last Updated: Nov 23 '10 at 09:32 AM