3D lines?

How can I create 3D lines? The current one I have looks flat when it collides with the player.

Does this work?

public class ScaledCube: MonoBehaviour
{

void Start()
    {
        GameObject cube=GameObject.CreatePrimitive(PrimitiveType.Cube);
        cube.transform.position = new Vector3(0, 0.5f, 0);
        cube.transform.localScale += new Vector3(0.5f, 0.5f, 3);
    }
}

How do you currently create lines? And what do you expect them to look like? Do you have some code that shows your line drawing? And are you perhaps using a Line Renderer?

Like @csofranz asked, how are you currently doing it? probably with the line renderer.

What i did to get this is create a model, a 1 unit long cylinder and a pointy cap, seperate meshes, then i use “coding and algorithms” (as the media likes to say) to place them in the scene and resize the cylinder to fill the line (not strecthing the pointy end).

I can give you the code when i’m back home, but it’s rather simple, i got it up and running in less than 15 minutes.

Yes I’m currently using line renderer with raycast. They are supposed to be lasers that follow and damage the player.

That’s why your line Looks ‘flat’: the line renderder creates ‘lines’ by creating small, long ‘billboards’ that orient towards the camera, as documented here. If you are simulating a laser, perhaps try a small (that you then make veeeeeeery long in one Dimension :slight_smile: ) cube or capsule as Sparrow’s already suggested (a cube uses fewer tris for 99.9% of the same look). To avoid flatnes, don’t use a surface shader and so there are no shadows cast onto the laser ‘beam’.

Thank you. I’ll look into it.

This also works with plain flat-ended cylinders and spheres. Can use the one in Unity if you remember it’s length 2. Place spheres exactly at each point (the ends, but more if the line goes, bends, goes, bends … ). The sphere perfectly covers up the ends and look like a nice, smooth ball-joint. It’s the same idea as having a rounded-cap, except you don’t need to adjust the angle.

Ofcourse if you know the length you can account for it no matter what it is.
I made a mesh that is not a perfect cylinder, it has some lines goins through it(like grooves cut into it), and if i’m already making one having it at a length of 1 makes the equations a lot cleaner