Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Bullet trajectory

Discussion in 'Scripting' started by Unity_Flowz, Jan 5, 2021.

  1. Unity_Flowz

    Unity_Flowz

    Joined:
    Jan 5, 2021
    Posts:
    10
    Hello, i'm new to unity and c# and i'm trying to create a vr shooter, i would like to create a preview with a line renderer of the bullet trajectory (straight line) which disappear on the collision of the bullet with a wall or a player. Is someone able to help me with acual code ? thanks in advance
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,697
    Use Physics.Raycast to find where the line will intersect with an obstacle (or not). You can just use the origin of the ray and the hitpoint of the ray (or if no hit, then just a point n distance along the ray) as points for the LineRenderer.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    That's not how this forum works. You write the code, you run into issues, you ask here. :)

    If you have no code, start with youtube tutorials. Doesn't even have to be VR. Just understand what you're trying to do... it's very simple and common in games to do this so there are plenty of examples to learn from.

    If you have an actual issue with actual code, how to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220
     
  4. Unity_Flowz

    Unity_Flowz

    Joined:
    Jan 5, 2021
    Posts:
    10
    Oh, I'm sorry, I didn't mean it in this way, I didn't want a full code or something like that just small function example to guide me on the right way.
     
  5. Unity_Flowz

    Unity_Flowz

    Joined:
    Jan 5, 2021
    Posts:
    10
    thanks you i will try