Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Eric H · Nov 29, 2010 at 04:08 AM · raycastdamagebulletshealth

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Uriel_96 · Nov 29, 2010 at 04:43 AM 0
Share

I forget to put spwan at the first

avatar image Uriel_96 · Nov 29, 2010 at 04:48 AM 0
Share

another thing, you have to put this script to your weapon or whatever you wana call it

avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges