Fixed size trail renderer
Asked Answered
B

2

0

I am working on SFCave 2d game.
For this I am using trail renderer to show line behind player. At present I have implemented basic functionality of trail renderer and it is working fine.

Now I want following changes in basic trail renderer.

  1. I always want fixed size trail renderer not change size of tail based on position
  2. At start of game, right now there is no trail drawn but I want some specific size trail to be drawn at start also.
  3. In original game there is dotted trail is created so for implementing this what is the basic concept?

Please give some suggestions in this. If any market plugin can help me in this then suggest this also.

Bonaventure answered 4/3, 2024 at 18:36 Comment(2)

@Bonaventure : Did you managed to achieve this trail?? If Yes Plz help me out with the same.

Periphrasis

No at present I can't able to figure out solution for this problem.

Bonaventure
D
0

Hey there, I’ve also got the same issue like you, here’s the answer I came up with (actually pretty simple):

Create a new script and add it to the gameObject:

void Update()
{
   trailRenderer.time = Mathf.Abs(1f / rb.velocity.magnitude);
}

This basically just checks the current speed the rigidbody has and then turns the time around to make if fit the current velocity magnitude. @Bonaventure

Deerstalker answered 4/3, 2024 at 18:35 Comment(0)
C
0

I’ve implemented line renderer with adjusted positions to simulate fixed length trail. I believe performance can be improved, but there is raw implementation anyway:

Implementation of fixed trail using `LineRenderer` · GitHub

Carrara answered 4/3, 2024 at 18:36 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.