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 wesley · May 14, 2011 at 10:20 AM · hitshowshield

if shield got hit show

hey guys i know i heve alreddy asked somthing like this but maybe you will know what i want with this its a simple idea i have a force shield arround me

now you see it all the time i want it to only show everytime it gots hit

i have the mashine gun and the standard rockerd louncher from the sirst person tut so both rigidbody weapons and raycast weapons

could you please make a script for me i dont know the codes

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Cery · May 14, 2011 at 11:08 AM

Here is my way how i would make it: The shield must have a collider with trigger activated

var Shot : boolean = false; var Timer : float;

function Update (){ //Normaly it's not showen renderer.enabled = false;

if (Shot){ //The time wich defines how long the sphere is showen Timer += Time.deltaTime; //If You make 0.1 its shorter showen if you make 2 it's longer showen if (Timer < 1){ renderer.enabled = true; } //If the time runs out it's dosen't showen else { renderer.enabled = false; Shot = false; } } // Reset the Timer else { Timer = 0; } } // This change Shot if something touches the Forcefield function OnTriggerEnter (){ Shot = true; }

Good luck I hope it works Cery

Ps: There is a better way than mine but i don't know how. Sorry for bad english

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 wesley · May 14, 2011 at 02:56 PM 0
Share

yeah it works but when i set the tomer to 0,1 it stil stays to long in face its like one second how do i fix this

avatar image Cery · May 15, 2011 at 10:24 AM 0
Share

Around one second? Thats unusualy but you can sett it to 0.01 or 0.001 it's your choise. You can make it also only one frame you must only say if (Shot){ renderer.enabled = true; Shot = false;} else { renderer.enabled = false; But i thing one frame is to short you wouldn't see it. Cery
Ps: $$anonymous$$aybe your Framerate is too bad $$anonymous$$uch poly's in your scene? Sorry for bad English

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

Detect Shield Mesh Sides Hit 1 Answer

shield if hit get visible? 0 Answers

how do you create sound when two objects hit one another? 2 Answers

Making raycasts go to the centre of the screen 1 Answer

what is the best way to detect if an object has been clicked on? 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