1
\$\begingroup\$

I'm very new to Unity (not to C# and programming as well) but I managed to achieve some goals very fast. But some concepts I still don't get in their full aspects.

I'm developing a small multiplayer game called skeet. It's about clay pigeon shooting. I have a static 2D scene, with 3 assets: A gun, a bullet and a pigeon. These sprites I'm able to deploy on the scene by an event driven script and I'm able to react on collisions between objects.

I reached the point I have to animate the pigeon and the bullets. First I have to animate the pigeon moving from border to border in a random direction on a random height. Second if a player presses its key to shoot its bullet must be animated from the bottom of the screen straight upwards.

My current idea is to create some animations as assets and to assign them to the sprites I'm creating dynamically. But I don't know what I need in the Unity GUI and in the script.

I'm not looking for a ready to run solution but an ordered list of concepts and advices I have to take a look into.

Edit:

The bullets and pigeons are created dynamically and should be destroyed after the animation finished (by reaching any border of the screen or a collision). So I need to create an animation with assignable position parameters.

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$
  1. Make sprite sheets for both your animation needs.Like flying animation for pigeon.
  2. Next thing you need is to look into Instantiating Game Objects in Unity, refer Instantiate a GameObject.Its an easy to code randomize spawn position for pigeon using Random.range
  3. There are tons of ways you can move your bullet and pigeon in the scene ,one of them being altering transform.position of the object.You can again randomize the direction using Random.range or random.value.

This pretty much covers everything you need to do for your project.Also refer Unity script manual time to time. Good Luck !

\$\endgroup\$
2
  • \$\begingroup\$ 1. Using static sprites for beginning. Changed it later. 2. Already accomplished - mentioned in Q. 3. Also found a way with OnUpdate - scripted transitions. But looking for a way to use AnimationController. Don't like strictly avoid benefits of UnityEngine by script only. Must be a simple solution of "Prepare AnimationController, Create GameObject + SpriteRenderer, attach AnimationController to GameObject. Struggling here. After digging something's coming up: An animation is not a movement? If so, then I'm looking for a movement and not an animation. \$\endgroup\$
    – codekandis
    Commented Feb 9, 2017 at 4:43
  • \$\begingroup\$ Simple solution for your problem is to make an animated pigeon sprite instead of a static one.Make it as a prefab and instantiate that prefab with random position.Also you can move the instantiated object to random direction with script.Its easier to manage collisions with movement script. \$\endgroup\$ Commented Feb 9, 2017 at 4:55
0
\$\begingroup\$

There is no need to do that when unity offers sprites and spline based animation for you to do your animation it would be a right approach for you to follow the already suggested way to animate rather than thinking of new methods to do stuffs you could probably do those things when you go higher level and ask these doubts to unity folks themselves.:D

\$\endgroup\$

You must log in to answer this question.

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