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 BrettRiet · Apr 03, 2011 at 03:22 AM · triggeraidamagezombie

Damage trigger?

I am trying to make the ai have an invisably box infront of them and when i am in side the tigger box i will loose 10 hp a second? i cant find any tutorials or scripts to do this EXACTLY i cant come up with scripts on my own i have been tring to modify ones i find on the internet and other together but no matter how i put it it desnt work can someone post a script that would be VERY Simple to modify or needs no modifications at all?

Comment
Add comment · Show 1
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 BrettRiet · Apr 03, 2011 at 04:22 AM 0
Share

I have done it after many many test and tests i have made the script work thanks!!

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Justin Warner · Apr 03, 2011 at 03:53 AM

function OnCollisionEnter(collision : Collision) { if(collision.gameObject.tag == Player){ collision.gameObject.//Whatever you want to edit on the player... Get their component and change what you need, anything... }

}

This'll work if you make the AI have a larger collider, then this'll run, and you can edit whatever is needed...

Read this page for what kind of things you can do: http://unity3d.com/support/documentation/ScriptReference/GameObject.html

Comment
Add comment · Show 5 · 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 Justin Warner · Apr 03, 2011 at 03:54 AM 0
Share

Also, to make it per a second... I'd get the time, add on 100 ms, then check it only when the new time (with 100 ms +), is less than the time time... If that makes sense... look at time.time

avatar image BrettRiet · Apr 03, 2011 at 03:56 AM 0
Share

But what do i add to make it apply damagewould i put after the last period "if (player) { player.ApplyDamage(10000); }"

avatar image BrettRiet · Apr 03, 2011 at 04:00 AM 0
Share

i understand what you mean but i don know how to right scripts just i can kind of recognize some parts and modify them so i cant really and the whole apply damage and time.time.

avatar image Justin Warner · Apr 03, 2011 at 04:29 AM 0
Share

Well, to be of all honesty, you're going to have to learn how to write code... It's a requirement in my opinion to really do anything with Unity... If you spend about 6 hours going through a script, and understanding how it works, and go through the API (Linked to it), you can easily figure it out... Every thing in the API has examples in both Javascript and C#, now you just have to take the time to go through it... If you need guidance, post what you can come up with, and I'll be glad to edit it and make some changes for you, same with others... Not going to "just write a script" for you =).

avatar image SGPascoe · May 04, 2012 at 04:49 PM 0
Share

I've been using unity a week so don't take my word for granted and correct me if im wrong, but I would set two vars..

var damage = 10 Private var health.Health

/ I have a 'Health' script on my player model that deter$$anonymous$$es it's current welfare with a static var /

//then you can say

if(collision.gameObject.tag == Player){health =- damage}

//to damage the player's health by however much you have set the damage variable.

I have also just noticed I am a month late not a day late.. it is not april anymore..

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

Attack Script problem please help 1 Answer

Disable a target after trigger exit? 1 Answer

Ai that applies damage in collision? 1 Answer

How to create/fix fire damage script???? 1 Answer

Zombie attack script help 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