I would start with the beginner ones first, The Survival Shooter one is for 4.6 and should translate over well.
I have done all the other projects. I’ve been working through them to try to learn how Unity works, I was hoping that the further I got the more up to date they would be. I managed to figure out where I needed to insert “GetComponent” for the Space Shooter and to refer to the DoneScripts if something wasn’t working on mine. It’s mainly where something has seemingly completely changed that throws me, like the GUI, Lightmap baking. In future I will be sure to make more use of the forums.
First of all thanks for this great tutorial! This really helped me much to get easily into Unity. I started from scratch in Unity 5.0.1 Personal and I haven’t had any bigger issues. Just minor problems with Fog, lights baking etc but this is something I can definitely live without. The scene lighting is still nice and other stuff just work fine.
I also vote for not to remove this great tutorial as it’s value is still considerably high and it doesn’t matter much if some part doesn’t work perfectly in Unity 5. With a little help of the great Unity documentation a solution can be usually found.
But stop talking about well known facts :). I’d like to also bring some value here to the forum.
I’d like to disscuss the universal script for single door a little bit.
IMO the script looks good from the basic perspective but it might be improvet a bit.
I see the following problem with door interaction (colliders) counts:
- in case key is required and player hits the door sphere trigger collider, no count is added. But in case player leaves the door trigger collider, count is decremented which is not correct. In case enem(y)/(ies) are nerby (hitting the door trigger collider) and player approaches to the door and then leaves (he can also repeat this process a couple of time), the door will be closed as count gets to zero (and enemies get squashed (in ideal case
) inside the door).
Possible solutions:
- to decrement count by player only in case player has key (in case door requires key). Not ideal solution in the real life. I guess the door shouldn’t be closed in case enemy opens the door, player enters door (as it’s open) and enemy leaves (I know it won’t leave but shoot player instead
). - to create bool playerIncrementedDoorCount variable. In case key is required and player doesn’t have key, this variable would be true only in case door is first open by enemy and player hits door trigger collider before door close transition is completed.
Then in OnTriggerExit we might check the bool variable and decrement door count based on this. - to check whether player or enemy is not colliding in OnTriggerStay in case door count is zero.
It can be easily tested by putting non moving enemis in front of the door and then move them manually and also move player manually.
I’m planning to attach script later, hopefully today, working on that now.
As promised here is the fixed universal door script.
Description directly in code in OnTriggerStay method.
Basically the door should behave like real world automatic door.
If somebody with key card enters door zone, it’s opened but it cannot close until the last object leaves the door trigger zone.
Also I play access denied clip at position instead of switching AudioSource clip.
To test just put 1 or 2 enemy clones + player to the following position:
char_ethan: -1.35, 0, 8.18
char_robotGuard: -0.75, 0, 7.331
char_robotGuard 1: -1.652, 0, 6.781
run scene and manually reposition the 3 objects in scene view.
I kept the Debug.Log on to display _count variable.
2074635–135406–DoorAnimation.cs (3.41 KB)
When I originally followed this tutorial chapter 4 wasn’t out. I upgraded my project to Unity 5 and did chapter 4 last night. No problems whatsoever. The only minor issues were some UI differences between Unity 5 and 4 and some obsolete functions the console told me how to fix.
My project is however quite different from the official one as I’ve extended it quite a bit and changed quite a few things. I’ll upload my project when I’m done with it for people to look at. This is an excellent tutorial for learning some Mecanim tricks. I learned a ton from Chapter 4.
@Adam-Buckner_1 I feel you’re already removing too much from the learn/tutorial section. There are quite a few old tutorials I’d like to see there still. Like the first person shooter one, the 2.5d platformer or the 3d platformer (the Lerpz tutorials). Just put up huge disclaimers and leave them up in my opinion. The assets are neat and there are some cool tricks in them still. It’s a shame you have to remember to make an offline copy of the tutorials in case they get removed from the official site.
Hello guys,
I won’t bore you with all the details of what I’m doing, it’s suffice to say that I’m using the Stealth tutorial 406 to add enemy shooting to my project.
Now when the player gets close to the enemy, within 15 metres - I’m not following the tutorial exactly as I don’t really understand most of it - the robot goes into the shooting animation. All good so far, and then a script that is supposed to grab the value of the animation curve of the Shot parameter in the Shooting animation and signal a value greater than zero to create the "laser’ effect. However the script only ever returns a zero and can’t figure out why.
And I am really hoping that you guys could tell me what is wrong with the code.
The script is below it’s really straightforward, but, I can’t figure out why its not working:
#pragma strict
//shooting script unlikely to work
// var unlikely: boolean = true;
public var shotClip: AudioClip;
public var flashIntensity: float = 10f;
public var fadeSpeed: float = 10f;
private var anime: Animator;
private var laserShotLine: LineRenderer;
private var laserShotLight: Light;
private var isShooting: boolean;
var player: Transform;
function Awake(){
anime = GetComponent(Animator);
laserShotLine = GetComponentInChildren(LineRenderer);
laserShotLight = laserShotLine.gameObject.GetComponent.<Light>();
laserShotLine.enabled = false;
laserShotLight.intensity = 50f;
}//end Awake()
function Start () {
}//end Start()
function Update () {
var shot: float;
shot = anime.GetFloat("Shot");
//print("shot: "+ shot);
if(shot > 0.5){
print("Success!!!!!!!!!!!!!!!!!!!!!!!!");
}//end if
}//end Update()
If you download the tutorial assets there’s a done folder in there with the completed projected. You could look in there to see how they do it if you’re not able to follow the tutorial yourself.
From looking at your script are you ever playing the Shot animation? It looks to me like you’re trying to read the value from an animation you’re not playing.
Thankyou for replying :).
Ok, the enemy is moving through the different waypoints that I have set, the navmesh agent is also set so the models go around objects as they are supposed to, and when the “player” approaches them they do actually go into the shooting animation with the arm outstretched - with the recoil - so does that give you any ideas as to what is going on?
IIRC, movement and shooting are basically in different scripts. Most of the movement stuff is covered by tutorial 402 and 407 in an “Enemy AI” script and shooting is covered by tutorial 406 in the “shooting” script.
I’m currently working on this project myself so I’ll have a looksy.
I would still recommend that you download the project assets and compare your project to the done-version in the tutorial assets. The entire project is on the asset store. Especially considering you’ve said that you’re not following the tutorial exactly. Not easy for us to know what else may be different or wrong in your project by just looking at this one script.
My version is also very different from the tutorial, but I have the completed tutorial in a separate project so I can look at it if something I’ve done doesn’t work correctly.
It’s hard to say really. I tried renaming my parameter in the animator and then I got a warning. So that’s not your problem unless you are getting a warning.
But have you made sure there actually is a curve on your shooting animation?
What I don’t understand is the relation between the curve and the parameter. It seems like this doesn’t work at all if you don’t create a parameter or it hasn’t got the same name as the curve. Is this just automatic? There’s no place in the project that we actually feed the value from the curve to the parameter. Normally you feed information to the parameters and in turn drive your state tree, but here the parameter gets its information magically if you’ve named them the same. Any solution that relies on your naming things identically multiple seemingly unrelated places feels like a convoluted solution to me.
I would much rather prefer it if we had to read the curve from the animation ourself. That way we wouldn’t need to define “Shot” and “AimWeight” as parameters in the animator either. After all we know we already know we’re playing the shooting animation.
But I feel like a lot of the solutions presented in this tutorial offers very little control and I probably wouldn’t use them myself. I feel like animation should never drive gameplay, it should just be an effect of gameplay. Or something like that. Not sure how to word it.
You should say in the code “Shoot()” and then play the recoil animation. In this tutorial it’s completely opposite.
I don’t either - and I don’t understand how the AimWeight works in “raise” and “lower” animations as this value is never used in any of the code.
As you also say a lot of of solutions are ones that I would never use, and don’t allow you to test out certain sections before running the code as a whole - which I think is essential to learning. Which I why I set little goals as I went along, such as getting the models to move, then settings waypoints and getting models to move between them, setting the NavMesh agent so the objects don’t magically walk through stuff (even though it was funny), getting the models to recognise the “player” being in range … now shooting.
I wish there was some way of setting the value of “Shot” in the animation itself a bit like a keyframe - like at this point in the animation set Shot to 1, then at another back to zero, and be able to access that.
Anyway, others have reported that everything works fine so I’m obviously doing something wrong.
That part I think I do understand, in fact I think I understand all of it now.
You have this bit in the EnemyShooting script for the AimWeight:
void OnAnimatorIK(int layerIndex) {
// Cache the current value of the AimWeight curve.
float aimWeight = anim.GetFloat(hash.aimWeightFloat);
// Set the IK position of the right hand to the player's centre.
anim.SetIKPosition(AvatarIKGoal.RightHand, player.position + Vector3.up * 1.5f);
// Set the weight of the IK compared to animation to that of the curve.
anim.SetIKPositionWeight(AvatarIKGoal.RightHand, aimWeight);
}
I think OnAnimatorIK() is called every frame like Update() on objects which has an animator component on them and have a layer with the IK Pass toggle enabled. In our case the Shooting layer on the guard’s animator controller has the IK Pass toggle enabled.
In the raise animation AimWeight has a curve which goes from 0 to 1, in the shooting animation AimWeight is always 1 and in the lower animation AimWeight goes from 1 to 0. This makes the enemy point his arm at you based on the above code in OnAnimatorIK().
In the EnemyAnimation script the Shooting layer is set to full weight:
// Set the weights for the shooting and gun layers to 1.
anim.SetLayerWeight(1, 1f);
anim.SetLayerWeight(2, 1f);
This would make it take control over the entire character if it wasn’t for the avatar mask which tells it to only animate the arm. It also doesn’t do anything until the guard actually sees the player because the default state for that layer is empty and the raise animation state is only triggered by when the PlayerInSight parameter is true which we actually do control through script and not curves (thank god :p).
When the guard sees the player it goes through all the states in the Shooting layer one by one depending on the conditions met.
The worst part about this is that it’s impossible to google for “animation curves” as that’s a completely different thing. So it’s unnecessarily hard to find info about these curves that you define on your animations. I think they’re a replacement for the old animation events. I honestly think his mention of them about 1 minute into this video is the best we get: https://unity3d.com/learn/tutorials/projects/stealth/enemy-animator-controller
I still think this is horrible design. It’s one of those “it just works” parts where I would very much prefer it to require a bit more code to work. From my understanding if you name a parameter in your animator controller the same as a curve defined on the animation (either by accident or on purpose) it will automatically read the value from that curve. I have no idea what’ll happen if you at the same time try to feed a value to the parameter through script like you normally would.
And I’m sorry to say I still have no idea why your Shot float never goes above 0. I think you’ve skipped an essential step somewhere. ![]()
I also very much agree with you about the style of some of these tutorials. I’m guessing it’s a lot faster to make tutorials like these, but they’re basically just breakdowns of the project in question. You have entire sections where you’re just writing down what’s being written in the video with no clue what the end result will be. I feel like they are not very much suited for beginners and more experienced Unity users would just download the finished project and go through it at their own pace and pick the parts they’re interested in.
A tutorial approach where you write the code for running forward, showing the result, write the code for going sideways, showing the result, tweak the code a bit, show the result etc. is a much better approach to video tutorials in my opinion. But it would also probably mean 40 minute videos instead of 10 minute videos.
Thanks for the explanation on AnimatorIK and the use of the AimWeight it’s starting to click together now - only slowly though, I’m absolutely exhausted from the 2 previous nights of martial arts and more to come this week, when I finally get a break and get to think about it will be a lot clearer :).
I think you are right - I did numerous searches for animation curves and the results were for “animations” using graphics primitives and not mecanim related. That one minute video was the only one I found on that was on mecanim curves and events!!!
I’m getting onto that - I followed your advice and downloaded the “whole” Stealth package including the done scripts and scenes - previous to that i only downloaded the needed models - I did that before I went to bed last night, I already have a couple of ideas. Thank goodness they have the “done” files in that package.
I choose to live in hope :p. If I ever get competent at this stuff - I would like to do tutorials very much in the manner you described - it’s the getting competent part that’s the problem
.
Thanks for all the help
.
Warmest Regards,
CK.
Sadly, I don’t have control over the final content on the Learn site. I can make my opinion known, and occasionally have been know to become argumentative over a point here or there, but that final decision is not down to me.
I have saved all of these tutorials in my personal collection. I have them in dropbox somewhere; the v1.x FPS pdf, the Lerpz tutorials, Penelope, etc…
Making them available? It’s such a double edged sword.
For example, we have maintained the availability of a version 3.x Car Tutorial, for which we were recently and deeply criticized, as it didn’t “work right out of the box” and was “riddled with errors when imported in Unity 5”, etc… When we spoke with the people involved they felt very strongly that these projects either need to be maintained or removed.
In many cases, maintaining them is not possible, so - at least according to their opinion - the only other option is to remove them.
As you can see, these decisions always put us in a bind, and it’s difficult to please everyone all the time.
We still do have some seriously venerable projects available. Penelope, AngryBots, and even StarTrooper are still available, as well as the Car Tutorial linked above.
Now, in my humble opinion, if I’m going to spend a large chunk of time upgrading an old project (which I just did with Roll-a-ball), especially one that may have a number of deep issues due to age, I would rather spend that time creating a new fully functional and polished project designed from the ground up for the newest version of Unity which directly addresses the the learning needs of that version.
Perhaps we can find a way to distribute some of these older projects, or at least their assets, but I’m not sure the best way to accomplish this.
Not trying to be a “Cat amongst the pidgeons”, but - there are some games that build in the animation playing into the game play. Probably both as an intent to control the game play and to solve the problems of playing complex animations during game play.
Guild Wars 2 comes to mind, as I’m playing it. There, the skill animations are timed to the skill itself. Some have additional mechanics, like cooldowns, after the animation stops playing, preventing re-using the skill, even if the animation is done. This has an interesting effect on game play. The character makes a move and is committed to it. There are certain skills, with their animations, that can lead to other players predicting the opponent’s move (either NPC or PC), which can lead to more life-like game play. A skill that requires a long “back cast” or prep time can be telegraphed to the opponent, so needs to be carefully handled. Players and their opponents can’t interrupt their own animation in many/most cases, and need to let the skill and it’s animation play out before using another skill.
Now, this won’t be that great in say, PvP death match with guns like Day of Defeat or Counter Strike, unless the animations are very short.
I guess, tldr; is just saying that having animations drive the game play is not necessarily a bad paradigm if you build your game around it.
Have you looked into “Animation Events”?
http://docs.unity3d.com/Manual/animeditor-AnimationEvents.html
This was one of the first official tutorials from the Learn site, which was made when I was doing nothing but the live training sessions, and I do believe it fell a little out of scope. It is an intermediate tutorial, but yes, it’s more of a description or explanation rather than a learning tutorial in many cases. There is a lot to learn from it, but it’s not as granular as it could be.
But I think you’ve identified the issue. For a project of this scope, it would take even longer to cover if done in a step by step manner, and it’s already very long as it is.
I’m glad you’re making headway! (We won’t delete this project just yet…)
Not trying to be a “Cat amongst the pidgeons”, but - there are some games that build in the animation playing into the game play.
Yeah, I realized that was a very subjective opinion after I wrote it. In nearly every third person game like Bloodborne, Dark Souls etc. you have to wait for animations to finish before you can take your next action. Which is precisely why I can’t play those games. I feel like I’m not in control. But they are obviously very popular games. I can accept it in a game like GTA 5, but not in a game like Dark Souls where one wrong move gets you killed. If I feel it was the game that killed me and not my own actions I instantly rage quit. ![]()
(We won’t delete this project just yet…)
Please never do.
Just the assets themselves in this tutorial are worth keeping up forever in my opinion. They are so modular you can make practically any game you want with them. And they are way higher quality than what would be needed for a top down game like Stealth. I’m still fiddling about with this project and my game looks very different from the tutorial game. I’m using the 5.x standard assets third person character with a GTA 5 style camera, I’ve added a hacking mini game, I’ve fitted roofs to the buildings and upgraded all the materials to the standard shader, all using the included assets. It would be a shame if the project was ever removed in my opinion. As a pure hobby game developer (at least for now) producing assets is the one thing I’m not keen on doing. So having tutorial projects to dissect, no matter how old, is always welcome. For example I still remember the old first person shooter tutorial and I would love to be able to create something out of those assets. The same with the Lerpz tutorials. I didn’t backup any of them while they were available. In fact I was looking for the 2D Lerpz tutorial when I was doing my Ludum Dare game. ![]()
I have experience with supporting old stuff from work and I know how much effort it takes, but I still think you should do it. I think if it was just made clear to people that these are legacy projects then they can only blame themselves if they download them and they don’t work. And you can ignore their support requests and criticism with a clear conscience.
Currently on both the stealth project and the car project on the asset store what’s written in bold is:
Requires Unity 4.2.1 or higher.
Requires Unity 3.3.0 or higher.
And then further into the description there’s a mention of them not being suited for Unity 5.x. So in my opinion it’s confusing for newcomers. You could easily download these projects today and expect them to work in Unity 5.x.
I would consider having a “legacy” section in the asset store as well as in the learn section of this site with very visible disclaimers. So anyone going there is doing so fully aware of the fact that they will have upgrade the project themselves if they are going to use it in a newer version of Unity, and it may break horribly. And if there are “official” support threads like this one they can also be mentioned in the project description. Otherwise they can just search the forums and/or make a thread asking for help with the project and perhaps someone else has already upgraded it to their version of Unity for them. If all else fails I’m sure some kind soul on these forums will help them without the need for Unity themselves to take any action. ![]()
