Author Topic: Trying to fire a frostbolt...  (Read 1398 times)


  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Trying to fire a frostbolt...
« on: February 21, 2016, 10:51:39 PM »

So basically I have a mage, I want to press a key down, trigger an animation, then fire a frost bolt.

I'd like to set it up so that I can switch skills and so forth, but I thought if I could get this basic pattern for one skill I could reduplicate it.

If I'm thinking big picture, I want 4 basic skill/action bar slots. By selecting a slot you could select a skill. For example, skill bar slot 1 has frost bolt selected. By pressing key down 1, that triggers a casting animation, then fires a frost bolt.

Anyone know a good way to do this?


  • Junior Playmaker
  • **
  • Posts: 90
    • View Profile
Re: Trying to fire a frostbolt...
« Reply #1 on: February 22, 2016, 03:20:07 AM »

I think in your case, you could setup an int variable that handles this; let's call it spellNumber. Default value is 0 so as not to cast anything.

When you press keyboard key "1" down, your variable spellNumber is set to 1. Then have an Int Switch action to compare the value at all times. The Int Switch cases should be 4 (1 to 4 for each spell). With each sending an event to the spell you would like it to be cast.

Hope that helps.


  • Full Member
  • ***
  • Posts: 198
    • View Profile
Re: Trying to fire a frostbolt...
« Reply #2 on: February 22, 2016, 06:38:33 AM »

How did you get on with mounting the horse?

Also just out of interest, is it a 2d or 3d game?

The basics of firing the shot is setting up the mecanim animator to transition from your idle and walk/run states to firing. Make the transition condition a trigger, make the return on exit time. (i assume youre using mecanim based on your horse question)

Setup the frostbolt to move on the z axis (set velocity in start state, maybe?), set it up so it destroys itself on collision or/and a set time. Save the frostbolt as a prefab.

Then create a key down state on character. When key is down send to state that sets animator trigger and creates an icebolt. Use wait action to time the creation of the ice bolt to the right point of the animation.

As for the selecting spells, Vallar's reply above should clear that up already I guess.

Also since you seem to be trying to learn by doing, I will suggest two really great tutorials that should cover loads of the issues you may be having. Both of these are hands on sort of, where it doesnt go through isolated concepts but actually shows how to build some game:

(this one is 2d, but dont take it for granted- my fave tutorial- I learned loads from this guy [also answers your magic firing question in one of the parts]).

(this is a nice 3d character setup tutorial- you will learn a lot - especially about animations. Goes on into enemies and camera control as the parts go on).

So yeah check them out, and let us know how you get on with it all.
« Last Edit: February 22, 2016, 06:45:06 AM by Zeldag »