Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 PrimeDerektive · Mar 13, 2010 at 08:39 PM · damagefpstutorial

Quick question about DamageReceiver script from FPS tutorial

I noticed in the DamageReceiver script from the FPS tutorial that the explosion variable it exposes to the editor is declared as a transform (where you're supposed to drag your explosion prefab that gets instantiated when the barrel detonates).

My question is, in the Rocket script, pretty much the same thing is done (an explosion is instantiated at the point of impact of the rocket), but the explosion variable that is exposed is declared as a GameObject.

Why the difference?

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
2
Best Answer

Answer by Eric5h5 · Mar 13, 2010 at 09:07 PM

It's usually a matter of convenience, depending on which you're going to be referring to more often. e.g.,

var someObject : GameObject;

function Start () { someObject.active = false; someObject.tag = "My Tag"; someObject.transform.position = Vector3.zero; // Can still refer to the transform component }

vs.

var someObject : Transform;

function Start () { someObject.position = Vector3.zero; someObject.eulerAngles = Vector3.up; someObject.gameObject.active = false; // Can still refer to the gameObject }

To some extent they're interchangeable, aside from how much extra typing you have to do to refer to the component you want, although referring to the Transform directly (someObject.position, where someObject is a Transform) is faster than getting the component (someObject.transform.position, where someObject is a GameObject), so ideally this should be used if the Transform component is being referenced a lot. It may be better in some cases to have multiple variables referring to different components in the same object.

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

FPS Tutorial AI Damage not Working 1 Answer

on collision damage 1 Answer

FPSTutorial: AI robot not taking any damage 2 Answers

FPSTutorial: AI robot not taking any damage! 2 Answers

AIs with guns and sentrys that fire 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