playMaker

Author Topic: Create Object and Play Animation [SOLVED]  (Read 7618 times)

hellbender

  • Playmaker Newbie
  • *
  • Posts: 2
Create Object and Play Animation [SOLVED]
« on: May 18, 2013, 10:30:12 AM »
Hello guys

I apologize from the beginning since I'm not a programmer, therefore my question could sound a bit naive.

I'm building a 3D gui and I'm using GameObjects as buttons. I'm facing an issue since I want to create instances of a 3D object and play an animation clip it comes with.
 I though that going for a Create Object and a following Play Animation could do the trick. I was wrong apparently.

Issue 1: I decided to use a spawn point to visually place different instanced objects accurately (a knife hitting a plank, the clip I did ends with the knife plunged in the plank). I placed a cube as a spawn point but the object generated appears in 0,0,0 instead of where the cube is.

Issue 2: I'm storing the animated object in a GameObject variable to be able to instance and animate other similar objects with subsequent transitions, but when i put a Play Animation action after a Create Object one, I can't select a clip to reproduce because playmaker says there are no anims on the object.

So then what should I do to clone and animate objects that contain animation clips?
« Last Edit: May 19, 2013, 05:43:34 PM by hellbender »

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
Re: Create Object and Play Animation
« Reply #1 on: May 19, 2013, 11:30:59 AM »
Hi!

Issue 1: If I understand your problem right, you need to offset your knife with anim so the last frame matches up with the plank. Usually problems with this is about the pivot point of the object.
An old 3d trick is to put different nullobjects (empty GO) in the top of the hierarchy so you can move stuff around.

Issue2: I think you cant select the clip, as your gameobject doesnt exist in the scene (it is probably a prefab in the project). It gets created at runtime and thus doesnt exist. I think this worked in earlier versions of PlayMaker, but it changed. I had the same problems

 Place the PlayAnimation actions on the instanced object (that has the animations). Then when you create the instance, store it in a GameObject variable. Then make a send event action to the gameobject stored in the variable. In my game DungeonMemory I use this technique to instance a chest on a revolving tile. When the tile rotates, a send event is sent to the chest to trigger a "popin" animation..




Hope this helps..

/s

hellbender

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Create Object and Play Animation
« Reply #2 on: May 19, 2013, 05:40:11 PM »
Hello Satrio

thank you for your help, even if already did what you suggested before you came at me. I did almost exactly what you suggested, in detail (for people having the same issue):

- I did the keyframe animation of my knife in my 3d package. The animation ended with the tip of the knife in 0,0,0 (origini of axis).

- I exported my animated mesh in Unity

- Created an empty game object in 0,0,0 (Unity world coordinates)

- Put my mesh with animation clips inside the empty game object (to be able to move it around) and created a prefab out of it

- Built a FMS on the game object prefab to listen for a global event and to address the child object to play the animation.
 
- Built an FSM animation manager to create instances of the prefab at given spawn points and fire the global event to play the animation.

It actually works as expected even if somewhere I read that it's wise to use as few global variables as possible.