- Home /
Health System Raycast Bullets
Hey, I'm new to Unity. I fooled around with it a few months ago and now I feel like I'm motivated enough to start up something. I have almost no scripting experience and I couldn't get the FPS tutorial from the Unity website (did they take it off? all old links take me to a corrupted dl)
I know that I should split this into two questions but I feel that they needed to be grouped together to help me understand any solutions you give me, and to make sure it's all either Javascript or C##.
I'm attempting to make a 3rd-person shooter, I haven't made any models or animations yet because it would all be wasted if I can't get the basics of the game working.
-First off, I need to be able to shoot bullets with raycast towards the mouse position. If possible I could also use ammo system of some kind, but I wouldn't need it immediately and if I don't get an answer here I'll just browse around the site or post a new question once I get the rest of the game up and running.
-Secondly, I need a health system that would accompany the raycast shooting script(s), one that lets me kill an enemy and enemies kill the player. If you could also include script that would make the enemies shoot back at the player with raycast (to test the player health script) that would be much appreciated :)
To be completely honest I can't seem to learn much from the unity resources (tutorials) and I am asking for answers here because I believe I'll get answers (and hopefully and explanations for why the script the way it is) that are easier to comprehend.
I know that people on the site don't like giving handouts but I'm at a loss here, if you asked me what kind of code I have already it would look something like this:
function update () { }
I want to learn this stuff, I just don't know where to start and how to string it all together.
Answer by Uriel_96 · Nov 29, 2010 at 04:42 AM
this at first may be a little difficult but at the time you will see its easy. for shoot use:
var bullitPrefab : Transform;
var revolutions = 0;
var numberbullits = 0;
var stop = true;
function Update(){
if(numberbullits<100){
if(stop){
if(Input.GetButtonDown("Fire1")){
if(revolutions==reloadbullits){
reload();
}else{
if(numberbullits<hola){
fire();
revolutions++;
numberbullits++;
}
}
}
}
}
}
function reload(){
revolutions=0;
animation.Play("reload");
stop=false;
yield WaitForSeconds(3);
stop=true;
}
function fire(){
bullit = Instantiate(bullitPrefab,spawn.position, spawn.rotation);
bullit.rigidbody.AddForce(transform.forward);
bullits--;
yield WaitForSeconds(seconds);
}
this script is very long and complicated for you but its really helpful.
another thing, you have to put this script to your weapon or whatever you wana call it
Answer by _Petroz · Nov 29, 2010 at 04:48 AM
You should definately start with a tutorial. We can help guide you in the right direction but we can't carry you to the destination.
Here is a great list of tutorials: http://answers.unity3d.com/questions/4897/how-can-i-start-learning-unity-fast-list-of-tutorials
Your answer
Follow this Question
Related Questions
bullets that do damage 1 Answer
Raycast Decals,Sound and MuzzleFlash not working too well 0 Answers
shooting raycast 1 Answer
Why does the wrong enemy die with this raycast? C# 2 Answers
health not subtracting 1 Answer