Hello Could someone make me a script that: -Looks at the player when they get too close -Then chases them -Then when they touch the player the player dies and make it easy for me to install, i have tried making so many scrips but i cant get it to work Thanks Mensley
look at the asset store, there are some AI scripts that you can buy! Otherwise you need to do it your self! Just try it, and if you have any problems post your code here and we will help you out. P.S. there are also tutorials out there. just google it
I'm not going to write it all for you but here's some of the basics in pseudo code. Code (csharp): void Update() { //Check if the player is close enough, use either a second collider or distance formula with //Ai's tranform and the players //Rotate towards player if(withinDistance) { //Look up RotateTowards and moving forward } } void OnCollisionEnter(Collision col) { Destroy(col.gameObject); }
There is a tutorial at Unitygems that does most of what you want. The topic is on rotation, but you should follow it just the same.
How far are you going to get if everyone makes your scripts for you? How much will you have achieved in a few years if everyone makes your scripts for you? Start now and build your own future, stop relying on others.
That's the farthest a thread named "Make my script for me" has ever gone with purely civil and helpful answers. That quote is usually the first response.
I Have Tried And Tried with tutorials with the scrips i was given at the unity training but it is just not working for me so i have asked for some help that is all
Asking for help is fine. Asking for someone to write scripts for you, is not the point of this forum. Those requests should go under commercial or collaboration. Post the scripts you have and where the problems are, and we would be happy to take a look with you. Did you even look at the tutorial I linked? It ends up with a playable environment with sleeping monsters that wake up when you get close or look at them and chase you. It has downloadable code even. Are you saying the tutorial didn't work and the code is broken? Or did you not even bother checking it out because you saw the word tutorial and figured that it was work that you were going to have to do? It doesn't seem like you are trying to learn this. It seems like you are being lazy and want someone else to write scripts for you.
I haven't had a chance i am about to look i have had a lot of homework as i am only in yr 7 and today i have the day off
i have just tried a simple script on that link but it didnt work error message Enemy1 script has not fineshed complition yet. please wait till it has complited any ideas
I have just tried making a new script and there was some erros that i dont no how to fix here is my script using UnityEngine; using System.Collections; public class EnemyAI : MonoBehaviour { public Transform target; public int moveSpeed; public int rotationSpeed; private Transform myTransform; void Awake(){ myTransform = transform; } // Use this for initialization void Start () { GameObject go = GameObject.FindGameObjectWithTag("Player"); target = go.transform; } // Update is called once per frame void Update () { Debug.DrawLine(target.position, myTransform.position, Color.yellow); //Look at target myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position, rotationSpeed), rotationSpeed * Time.deltaTime); //Move towards target myTransform.position += myTransform.forward * Time.deltaTime; } this script is just for moving the enemy and there is some sort of error in the look at target section it is a c#script any ideas
There's literally no way anyone can help if your error message is "There's some kind of error". Enable your console (Window > Console) and read off the actual error. Or, if there's no error but the behaviour is wrong, describe the desired behaviour and the actual behaviour in clear terms.
there are 4 errors and they are stopping me from using the game 1) Assets/EnemyAI.cs(28,90): error CS1502: The best overloaded method match for `UnityEngine.Quaternion.LookRotation(UnityEngine.Vector3, UnityEngine.Vector3)' has some invalid arguments 2) Assets/EnemyAI.cs(28,90): error CS1503: Argument `#2' cannot convert `int' expression to type `UnityEngine.Vector3' 3) Assets/EnemyAI.cs(28,51): error CS1502: The best overloaded method match for `UnityEngine.Quaternion.Slerp(UnityEngine.Quaternion, UnityEngine.Quaternion, float)' has some invalid arguments 4) Assets/EnemyAI.cs(28,51): error CS1503: Argument `#2' cannot convert `object' expression to type `UnityEngine.Quaternion' This is always were i get stuck i cannot fix errors as half the time i do not no what they are talking about
Please use code tags for codes next time. More info on that here: http://forum.unity3d.com/threads/143875-Using-code-tags-properly On-topic, your problem lies here: Code (csharp): Quaternion.LookRotation(target.position - myTransform.position, rotationSpeed) LookRotation takes in two arguments, both arguments are Vector3. The variable rotationSpeed is not a Vector3 so Unity throws an error. You can read up on Quaternion.LookRotation here: http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.LookRotation.html
These are basic C# fundamentals that need to be understood before you continue programming. I'd suggest doing a C# course first, we can't explain these errors to you because they are easily learnt and a part of the language fundamentals. Buy a one month subscription to lynda.com and do this c# video course.. http://www.lynda.com/Visual-Studio-2010-tutorials/C-Essential-Training/83789-2.html Good luck
Ouch. But... I agree with most of the commenters. This is supposed to be a supportive community, not some kind of free coders-for-hire nest. Whether you want or not to learn how to code, it's pretty offensive to some people to come and say "hey, I don't know how to and I need it done. Would you be so gentle to make it for me? (ah, by the way, expect no reward)". Although I differ from Meltdown's statement. We could explain those errors you get, but I think it'd be pointless, since you don't seem to know how to program, even you don't seem interested.
well that wasnt true i do want to learn and the way i learn was always diffrent to others i get exampes then take bits and pieces from i but that is in other things i didnt want whole big script just something to get ne started
/thanks mate it is looking at me and moving towards me although is there a way to make him go faster when i click on him there is an area to do that under the sripts name but no mater how fast i tell it to go it is going at snail speed i am going at about 10 and i would like it to go 8 any sugestions
These errors can be resolved with a simple google search, each and every one. Mensley is just lazy and wants people to sort everything out for him/her. Yes I'm being brutal and I'm being honest, but Mensley you're not showing any effort on your part nor seem willing to learn, but seem to want to do the absolute minimum while getting the community to spoon feed you at every step. As I've said... a.) Do that C# course I mentioned above, it's really good, and will give you the confidence you need to tackle C# and Unity in a much better way b.) Once comfortable with C#, do a few Unity tutorials on a variety of projects. c.) Go to www.unity3dstudent.com and go through each and every short video scripting tutorial video there Once you've done that, come back here and we'll be more than happy to help you with any places you get stuck. As it stands you've shown absolutely no effort on your part to teach yourself on the absolute basics, so why do you expect us to spend our time helping you? If you want to wade through the bog at every step, continue as you have here, otherwise follow my advice and even in a couple of weeks you'll be a lot more confident and well on your way to becoming a decent Unity developer. Good luck and this is nothing personal, just trying to help you
look i am not paying for anything i am only in yr7 which means first year of high school if your over seas i am looking on youtube at some guy who is helping me script and showing me what it all means. cut me a bit of sluck just wanted examples. and has been about 8 months since i did my course. and i had to stop not long after and i have lost the contact with thatguy so i have been fourced to ask for help i have been trying looking through my booklet with some simple scripts but there are things i don't want in there and when i try to edit them out i fail kk
ok i have a new part of the script and every thing is exctly like what i was watching (meltdown i will ajust later but i want the basic in) but there is a error and i have checked down to the line incase there was i typo but there wasn't heres my scripe code: public List<Transform> targets; public Transform selectedTarget; private Transform myTransform; // Use this for initialization void Start () { targets = new List<Transform>(); selectedTarget = null; myTransform = transform; AddAllEnemies (); } public void AddAllEnemies() { GameObject[] go =GameObject.FindGameObjectsWithTag("Enemy"); foreach(GameObject enemey in go) AddTarget(enemey.transform); } public void AddTarget(Transform enemy) { targets.Add (enemy); } private void SortTargetByDistance() { targets.Sort(delegate(Transform t1, Transform t2) { return Vector3.Distance (t1.position, myTransform.position).CompareTo (Vector3.Distance (t2.position, myTransform.position)); }); } private void TargetEnemy() { if(selectedTarget == null) { SortTargetByDistance(); selectedTarget = targets[0]; } else { int index = targets.IndexOf(selectedTarget); if(index < targets.Count - 1); { indexer++; } else { index = 0; } selectedTarget = targets[index]; } } // Update is called once per frame void Update () { if(Input.GetKeyDown(KeyCode.Tab)) { TargetEnemy(); } } } the errors are Assets/My Scripts/Player/Targetting.cs(57,28): error CS1525: Unexpected symbol `else' Assets/My Scripts/Player/Targetting.cs(67,14): error CS0116: A namespace can only contain types and namespace declarations and there is a warning that i don't know how to correct that may have somthing to do with it Assets/My Scripts/Player/Targetting.cs(53,25): warning CS0642: Possible mistaken empty statement it was made in c# if someone could help and nobody got up me that would be a real help ps i am boy
You have been told before to wrap your code in code tags provided in the Advanced Reply section. Make an effort and listen if you want to learn. if(index < targets.Count - 1); <---- You have a semi colon there you need to take out. That will cause allot of problems and other errors in a domino effect. There may be an extra "}" closing brace at the end of you code. It's important to format your code properly so you can see where things are missing or not lining up. If this code was from the Burg Zerg Hack and Slash Targeting tutorial, you need to do it again and listen carefully. There are typos and small mistakes. eg. indexer++; should be index++. Do yourself a favour and make a simple paddle or pong game, learn the basics of C# and unity. If your only 7 years old can you imagine what you can achieve when you 21. Do it correctly and start from the beginning! I know I had to.
No offence but Unity might not be the best tool for you to learn game development. It's not really a beginner tool, I'd recommend you start with something simpler, like Kodu: http://research.microsoft.com/en-us/projects/kodu/
Thanks mate that fixed up the problem and yes i am making a simple sort of game adding in on element at a time yes it was Burg Zerg Hack and Slash Targeting tutarial i find he realy helps and tells me what each thing is doing. usaly i can edit his mistakes but i couldn't see that one now i can go agian tomorrow thanks
actualy iam in yr 7 and i am 13 we had i guy come and train us but i lost contact with him so i have come to seek help here
mensley unity3d isnt a kids tool we are happy to help but please listen and follow what we say example u was told a few times to use code tags go u that may not be a big deal but its forum rules if ur not willing to open rules or even listen to them then helping u if a pointless waste of time as what we are telling u will go thu one ear and out the other ur method of making a game is kinda a bad idea as to make a good game u wanna have a layout and plan first otherwise ull be making useless items and stuff and take much longer to make the game so wat i would suggest is u sit down right a flow chart and game story line then start on it. as for coding ya its work ya its hard but dont ask ppl to do it for you ask for help but code it ur self read the ref pages and learn wat everything does on your own otherwise it makes you look bad also befor asking for help read the ref pages and if u still cant figure it out then come here state what u have tryed post ur code with and error msg and ull be more likely to gain help
I teach game development to University students and even some of them aren't read for Unity yet, far too much rope to hang yourself. If you're not capable of self learning at a very high level then you will be much better served working with something simpler for a few years as you develop your fundamental skills. I'm trying to help you get the most out of your desire to make games, because right now I see a very passionate boy with the wrong tools and poor guidance. I'm not sure who introduced you to Unity, but it hasn't been a terrible beneficial experience that you can pursue on your own. Trust me, find a simpler tool to work with, you'll be able to accomplish and learn so much more. You will also learn and improve at a much more rapid pace, right now with Unity you're just bashing your head against wall after wall without really leaning anything. Getting your script to run error free isn't likely to teach you why it was happening or how to avoid that from happening again, these kind of error messages are things you need to be able to identify and fix yourself based on what the error message is, with a good foundation of experience and understanding of the programming language you're just going to keep having problems you're unable to fix yourself. Again, I'd strongly recommend you give Kodu a try. It was designed as an introductory tool, you don't really need to know how to compose programs in code to use it, and you can make a lot of different types of games with it too.
Kodu isn't a simple version of Unity. It's a totally different engine, since it's more ludic, it's merely done to learn about programming logic and making games, whilst Unity is an industrial-scale engine. It might help you to learn how to do this stuff, but you should do more on your side. Try to figure out what can you do with Kodu, and what you can't. And, as Meltdown says, follow some coding courses and workshops. Unity needs this kind of knowledge. Another thing you might want to check out is Playmaker, a Unity plugin to program without scripting. It's very powerful, but has its limitations. Then if you want to break those limitations, you must know how to code.