Best way to render bullet tracers?

@Ronin I think you may have taken the suggestion above incorrectly.

I am not understanding how you interpreted @Albertos advice but maybe here is some more information. If the target is moving the collision and rigid body must follow along with it. Static rigid bodies will stay in place. Not sure why this would be a complete rewrite of things as it is a simple selection in the editor for your item that will be moving. I think I remember we discussed this same issue in this post.

1 Like

I mentioned the kinematic rigidbody because a moving trigger is not activated by a static rigidbody. Just in case someone would do the same.

1 Like

There’s a lot of information i need to process right now, i’m just concerned about losing my focus. I’m gonna get my head my together and look into this tomorrow. I’ll post here when i get some results. Until then, any comment i would make will just complicate things. Again, i thank everybody who tried to help me on this topic

Ok i did it. The damage is being dealt with the raycasting system while i fire the bullet with forces. When i inrease the speed of the bullet, you can’t tell the time difference between raycast hit and bullet’s impact. This is the code piece which launches the bullet entity

 var bullet = this.bullet.clone();
   
    this.app.root.addChild(bullet);

    var player = this.entity;
    var target = this.entity.findByName('target');
   
    this.force = new pc.Vec3();
    this.force.copy(target.forward);
    this.force.scale(this.gunpower);
    console.log(target);

    var pos = target.getPosition();
    var direction = target.forward;
    // Add it a little further if the player is already going fast
    // pos.add(direction.scale(5 + gun.rigidbody.linearVelocity.length() * 0.01));

    bullet.setPosition(pos);
    var bulletRotation = this.entity.getRotation();
    bullet.setRotation(bulletRotation);
    bullet.rotateLocal(0, 0, 90);

    bullet.enabled = true; //Must enable after setting position!

    bullet.rigidbody.applyImpulse(this.force);

I don’t know why i was so obsessed with doing this with raycasting, there’s no visible difference and this is much easier. I apologize for any trouble and annoyance i dealt to anybody who tried to help me. I have utmost gratitude to all of you. I also hope that other users who are struggling about the issue would benefit from this topic. Infinite thanks :pray:

1 Like