0
\$\begingroup\$

I'm using Unity 3D

Let's say the player is an ice cube. You control it like a normal player. On press of a button, ice transforms (with animation) into water. You control it completely different than the ice cube.

Another great example would be: Player is human being and has normal FPS controls. On press of a button human transforms into birds and now has completely different controls.

Now, my question is, what would be easier and better:

  1. make one object with animation transition and to stay in that state of anim. until button is pressed again
  2. make two object: ice and water. Ice has an animation of turning into water. So replace ice (with animation) with water object

And if anyone knows this one too: how to switch between 2 different types of player controls.

\$\endgroup\$
2
  • \$\begingroup\$ I think there are really two questions here that you should perhaps consider separating. 1 about contextually altering the control scheme (whether they are getting in a car or melting shouldn't make much difference) and one on transitioning objects between radically different physical states with animation (does it really matter if it's the player?). \$\endgroup\$ Commented May 28, 2014 at 10:46
  • \$\begingroup\$ Well, I don't want to separate them as they are kind of connected questions. \$\endgroup\$ Commented May 28, 2014 at 10:49

1 Answer 1

1
\$\begingroup\$

If your objects are not animated I'd make just a transform animation between first and the second. When you want to change the objects you just play the animation and stop at the end. If you want to change back, you just play the same animation backwards, to 0.

When you objects have their own animations it gets more tricky so in such case I'd make separate objects and replace one with another when transition animation ends. This way you wouldn't have to worry about too many animations at the same time, in the same object.

According to different types of controls:

Implement both in your game, so you can play as the ice cube and as the water (with selection at compile time for now). Then store somewhere your current player mode and in all your input methods like MouseMoved, KeyDown, etc. add a simple if( state == something ) and select which of your controlling code to run.

\$\endgroup\$
5
  • \$\begingroup\$ Thanks for quick reply. Just do I have to make 3 object than? 1. is human-- 2. is just animation of human turning into birds-- 3. are birds \$\endgroup\$ Commented May 28, 2014 at 10:27
  • \$\begingroup\$ Two objects should be enough: 1. A Human, with anims like walk, shoot, change to birds. 2. Birds, with anims like: fly. On changing Human->Birds you run anim 'change to birds' and when it ends you replace an object. On changing Birds->Human you replace the object first, set the anim to the end and run it backwards. \$\endgroup\$
    – kolenda
    Commented May 28, 2014 at 12:31
  • \$\begingroup\$ When changing from human to birds...after animation is over should I delete the human object and spawn birds object or is there a better way? \$\endgroup\$ Commented May 28, 2014 at 13:15
  • \$\begingroup\$ This should be the simplest solution but you can also try to just replace a mesh in MeshFilter and material in MeshRenderer. Going this way you'd need to put all Human/Birds animations into your object, but I'm not sure if it won't make any problems - just an idea to test. \$\endgroup\$
    – kolenda
    Commented May 28, 2014 at 14:19
  • \$\begingroup\$ I'll try it out \$\endgroup\$ Commented May 28, 2014 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .