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 Inan-Evin · Nov 24, 2014 at 11:57 AM · bulletlinetrail

Best Way For Tracer Effect Out of 3

Hello guys, i know that this question is being repeated but i did a lot of research and still couldn't answer the questions in my head. I want to create tracer effect for my bullets. But the thing is, in my shooting script i do not instantiate bullets, i use raycasting to shoot, also with an additional "check raycast" i handle bullet drops, accuracy, penetration etc. First question, this is the right thing to do right ? Little hard but handling shooting from gun script's raycast or instantiating bullet and using raycast over there, which is better ? I believe first one and thats the way i've done it. My other questions are about tracers.

First, i tried using Line Renderer for tracer effect, but since line renderer uses a method that line renderer needs a start point and end point, and is simply a line between those points, to create tracer effect in line renderer, i believe i need to add a value to it's first and last positions, which i couldn't accomplish. Something like this :

 lineRenderer.SetPosition(0,barrel.position + new Vector3(0,0,i));
 lineRenderer.SetPosition(1,barrel.position + new Vector3(0,0,0.5f+i));
 i += 1f * Time.deltaTime;

But as i said, I couldn't do it.

Second, how efficent is instantiating an empty game object with Trail Renderer on it, translating it to hit position and destroying it upon hit or penetrated hit. I do not look well about instantiating anything except shells and muzzles in shooting script, but i need to be sure, will instantiating tracers gameobjects with trail renderer cause an fps drop ? Considering the fact that lets say we fire a machine gun with 200 bullets and all of the bullets are tracers. ( not realistic but just to consider in max conditions )

Third, some people create empty game objects with Particle Systems on it. And on that particle system, there is just simply streched billboard particle with texture to create tracer effect. I tried this one, but particle instantiation stayed behind as we move the character. I mean it wasnt following the instantiate position simultaneously, as the character moves, couldn't figure out why. Also even i managed to create the effect without a problem, i believe setting the speeds of the particles according to hit distance can be a pain in the ass.

So I need some opinions guys, please enlighten me. What is the best way, i care about performance and usability.

Comment
Add comment · Show 2
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 sevensixtytwo · Nov 24, 2014 at 04:26 PM 0
Share

Seeing as I'm a fan of the Particle System method and have used it several times without fail, how exactly does it not follow the position? Is it not parented to your gun/muzzle/weapon?

avatar image Inan-Evin · Nov 24, 2014 at 05:36 PM 0
Share

There is a gameObject called shootPosition, child of my weapon. I use this code to instantiate particle system :

GameObject instantiatedTracer = Instantiate(tracer, shootHipPositionObject.position, transform.rotation) as GameObject;

And when I stand still, it fires from that position which is okay, but when i move it looks like it doesn't follow shootPosition's position. Let me explain with images :

alt text

alt text

first image, standing still, no problems. second image, moving to right and they instantiate from the circled area of the screen ( its like they cant reach they stay behind, in the image i couldnt catch them just in time but they instantiate over there.

Also with particle another issue is that, my particle system is box shaped, with 0,0,0 as scale. Only have velocity of 15 on z-axis. So they go straight forward, i wanted them to move to hit.point because otherwise it looks ridicilous, so i wrote this :

 if (hit.point != null)
 {
                             instantiatedTracer.transform.LookAt(hit.point);
 }

And another problems occur, they move to hit point when there is a hit, but if a fire into the air, they directly move to 0,0,0 position in the world.

EDIT: I now tried another way, i created a particle system in shootPosition object. And when i fire, i simply do this : prtS.Clear(); prtS.Emit(1);

it works okay, but how am i going to deter$$anonymous$$e where the particles will go ( i need them to go to hit.point because i use recoil and if they don't it doesnt match with bullet marks)

2.png (103.2 kB)
1.png (95.5 kB)

0 Replies

· Add your reply
  • Sort: 

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

27 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 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

Shoot in a straight line 2 Answers

Uncharted4-like bullet trails: Shader, Particles or Trail Renderers? 0 Answers

Drawing a glowing line from one point to another on update 1 Answer

Raycast visible bullets 2 Answers

Trail renderer algorithm? 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