[SOLVED] Bullet trail/Tracer rounds?

Hi,

The current setup I am using uses rays to add a bullet object at ray.hitPosition whenever actuator “fire” is active, but I want there to be a bullet trail that follows it. The idea I have is to add and scale a plane between the ray.hitPosition and ray source every time tap “fire” is active. The plane would then fade out using object color after a while and end object.

How do I do this, and is this the best way to do this, or is there something simpler?

Thanks :slight_smile:

That seems like a reasonable approach. I would expect this would work better for effects like laser beams or other energy/zapping effects since the results would be very straight and uniform. You might want to experiment using a cylinder instead of a flat plane.

For bullets/smoke you might need to spawn a number of smoke objects along the trail so you can give some variation to the smoke effect along the line.

I should have mentioned the game is 2d and I am looking for a very basic effect :slight_smile: It matches the style of the game.

Well, then a simple plane should work fine!

Edit: I did it!


def bullet(cont):
    own = cont.owner
    fire = cont.sensors["fire"]
    ray = cont.sensors["ray"]
    bullet = cont.actuators["bullet"]
    tracer = cont.actuators["tracer"]
    if fire.positive and ray.positive and own["ammo"] !=0:
        bullet.instantAddObject()
        bullet = bullet.objectLastCreated
        bullet.worldPosition = (Vector(ray.hitPosition)).xyz
        
        logic.globalDict['tracerlength'] = own.getDistanceTo(ray.hitPosition)
        print(logic.globalDict['tracerlength'])
        
        tracer.instantAddObject()
        tracer = tracer.objectLastCreated


def tracer(cont):
    own = cont.owner
    own.localScale.y = logic.globalDict['tracerlength']

Thank goodness for the blender documentation ^^

Make a plane facing up on z axis sized 1x1. On fire effect addObject and alignAxistoVect from player to target. Scale on local x axis 0.2 or whatever works in your scale for width and scale local y axis bu the distance to target.

Yeah I did something to about that effect. Thanks :slight_smile: