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 Borzi · May 23, 2013 at 08:39 PM · fpsparticlesprojectilespherecolliderhit detection

Possible Particle function?

I am playing around with different particle system methods and I was wondering if someone could help me out. I do not know how to turn of the sphere collider in script, as well as this error which appears: (25,1): BCE0077: It is not possible to invoke an expression of type 'UnityEngine.Transform'. In general I'm just curious if anyone could tell me if this type of system would work :)

Thanks!

 //Variables (START)_________
 //The particles that will Instantiate on hit
 
 var Particle1 : Transform;
 
 //Speed of the Bullet
 var bulletSpeed = 10;
 
 var expireTime = 10;
 
 //Variables (END)___________
 
 
 function Start () 
 {
 //A soon as the projectile is created, make sure
 //destroys itself
 Destroy (gameObject, expireTime);
 }
 
 function Update () 
 {
 //Sends the projectile forward
 transform(Vector3.forward * bulletSpeed * Time.deltaTime);
 }
 
 function OnCollisionEnter (hit : Collision)
 {
 if(hit.transform.tag == "floorMud")
     {
     Instantiate(Particle1, transform.position, transform.rotation);
     transform.renderer.enabled = false;
     transform.spherecollider.enabled = false;
     }
 }
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
Best Answer

Answer by Benproductions1 · May 23, 2013 at 11:21 PM

Hello,

Your error is due to you trying to call a variable as a function.
In your Update function you call transform(), but transform references the Transform component of the GameObject your script is attached to. You can't call a Transform as a function, it just doesn't work that way. What you can do is access it's position and so something like this:

 transform.position += Vector3.forward * bulletSpeed * Time.deltaTime;

This will then change the position of the Transform component of the GameObject to whatever :)

Hope this helps,
Benproductions1

Comment
Add comment · Show 3 · 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 Borzi · May 24, 2013 at 05:21 PM 0
Share

Thanks for the help! The problem with this method is that I get a really weird instantiation angle. I got the good o'l C# and wrote this script:

     //Variables Start
 
     //Quick Reference
     private Transform myTransform;
 
     //Speed of the Projectile
     private float projectileSpeed = 100;
 
     //Time till Projectile Destroys itself
     private float expireTime = 10;
 
     //Variables End
 
     // Use this for initialization
     void Start () 
     {
 
    myTransform = transform;
  
    //As soon as the projectile is created start a countdown
    //to destroy it.
  
    StartCoroutine(Destroy$$anonymous$$yselfAfterSomeTime());
     }
     
     // Update is called once per frame
     void Update () {
     myTransform.Translate(Vector3.forward * projectileSpeed * Time.deltaTime);
     }
 
 IEnumerator Destroy$$anonymous$$yselfAfterSomeTime()
 {
    //Wait for the timer to count up to the expireTime
    //and then destroy the projectile.
  
    yield return new WaitForSeconds(expireTime);
  
    Destroy(myTransform.gameObject);
 }
 }

And in another Java I still have the rest of the script. But the particle doesnt indicate a hit as it doesn't instantiate! Could you help me with this?

avatar image Benproductions1 · May 24, 2013 at 11:36 PM 0
Share

@Borzi, if you have another question, ask another question. Don't post a comment :)

avatar image Borzi · May 25, 2013 at 10:06 AM 0
Share

Oh okay I thought that was kinda "included" in my question xD Well thanks I guess.

avatar image
0

Answer by Synergetik · May 24, 2013 at 06:16 PM

For the sphere collider you can add : gameObject.GetComponent(SphereCollider).enabled = false;

or if you want to destroy the object just use destroy(gameObject);

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 Borzi · May 25, 2013 at 10:08 AM 0
Share

Thanks for you answer :) destroy(gameObject) would only destroy the Projectile immediately, whereas I wanted it to destroy itself after some time. Thanks for the gameObject.GetComponent(SphereCollider).enabled = false; though, i think its working (im kinda stuck because the whole system doesn't seem to recognize a hit).

avatar image Synergetik · Jun 09, 2013 at 03:07 PM 0
Share

You can just add destroy(gameObject, 1.0f)which will destroy the game object after 1 second or any other value you enter. Sorry for the delayed answer.

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

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

special advance gun attack 2 Answers

Android: FPS halt when doing things for the first time 2 Answers

How to speed up a trigger enter function? 1 Answer

How to create shoots 2 Answers

Particles , Altas or Separate ? 0 Answers


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