Im trying to make an easy game, but i seem to be in over my head.
I have made a 3d model of a evil toy robot, the old retro style that just walks a few steps, stops, opens up its chest and reveal a weapon, spins around its torso, shuts the chest doors, and walks on.
The animation of it its easy. Its just i want to make a script that takes the start/stop function of the animation into focus.
If i put my existing scropt, the robot will only walk towards the player even if it has stopped to spin around its torso.
I also want to add a soundfile for when its walking, and a different soundfile for when its spinning around.
Its a 3rd person game, kinda like the survival shooter tutorial that you can learn from here.
The robot should go for the player at all times. And if its possible, the spinning attack is the only time the player takes damage. Otherwise its ok if the player takes damage all the time the player is in the robots area.
Please help a future game dev
wow, ok. Firstly, nice concept for a first game. You’ll get more traction on the forums if you break things up a little bit. What do you currently have? what is the current problem? then build it up over time
(big open ended question, you’ll get big open ended general answers…)
in the mean time, you really should check out the animation and animation scripting sections in the learn pages. There was also a few sessions on adding sound/music to games in the live training I seem to recall.
oh, and for the different “stages” of the robot’s attack/progress you’re probably looking at a “state machine”, a good concept to be familiar with
Thanx for the fast reply.
Yeah, i was taking a breather and thought about how this would work out. Not just one script, but maybe a script for each state. Like you cut out different animation from one single animation.
If the animation goes from entry state “walking”, playing that animation, and that sound, going over from walking to “stop/attack” animation.
Was thinking about making the walk animation cycle just do one cycle. Like, left leg, right leg walk, then it can be re-used again seamless. If the walkcycle is used 4 times in a row, then the stop/attack animation comes in, the torso spins around 4 times, then it start walking again. Each sequence with its designated soundfile.
I have the sounds, i have just about done the model and animation. Im doing a bit of recon into how i should sum it all up with a script that would work.
unity’s mecanim animation system uses blending to seamlessly move between states, so you generally don’t have to worry too much about the exactitudes of x cycles in y state once the animator is configured. So long as the walk cycle is a complete loop (i.e. first can be seamlessly transitioned to from the last frame) it should be fine. There are also “animation events” for triggering sounds and other scripted effects (covered in learn section).
You’ll probably end up with quite a few scripts. Each one should handle one part of what you are trying to do, and communicate with the other scripts when they need something else to happen (don’t worry about this too much to start with, just be aware of it).
This is the motion i want to achieve.
But it should start directly from walk. Not start from standing still.
So the animation cycles ive made are called, walking, and attack.
Just switching between those two.
But the forward motion has to stop when it is in attack animation, and it is giving dmg when it is in attack animation.
While the soundfiles is playing in each animation clips.
Cant explain it any better i guess.
I have the sounds, and the animations.
What should i do next? To go from the walking state to the attack state, and do what it is suppose to do while it is in each state.
I can probably do a walking script where it walk toward the player, but what should i add in that script to make it go into the attack script, play the right animation, give dmg, and play the correct sound?
Please help
ok, there are basically two approaches with mecanim.
You allow the animation to move the gameobject (aka root motion)
You move the gameobject via script and feed those variables into the animator to control it alongside.
I tend to go with “via script” because I’m naff at animating
The tips didnt work. its not what i had in mind.
Is there no one that can help me out?
i dont want a complete code made, just a pointer on which direction i should go.
Im gonna use the ZomBunny C# code and play around with it. it has what i want, the enemy moving towards you, attacking at contact. all i want is to add an attack when the enemy comes close enough.
it has to do with the state machine i guess, but it probably needs two scripts to work. one for moving towards the player, and one that goes in effect when the playercollider gets hit. it should switch over to the attack script, and play the animation, and sound.
can anyone please help? and not just guess, and give me general answers?