Laser Shooting from off screen

Hi!
I am very new to game dev but I am trying to get my laser to shoot from the pink craft. On my editor it initially shoots from the correct position but when I hit space to shoot it is shooting from somewhere off screen.
Here is the link to my build.
Thanks for any help.
https://playcanv.as/p/szV32UV4/

Hi @Ashley_Solano and welcome,

Are you able to share some of your laser shooting code or even better a public project?

Looking at the minified code,

InputHandler.prototype.update = function(t) {
    if (this.app.keyboard.isPressed(pc.KEY_A) && this.entity.translate(.1, 0, 0),
    this.app.keyboard.isPressed(pc.KEY_D) && this.entity.translate(-.1, 0, 0),
    this.app.keyboard.isPressed(pc.KEY_W) && this.entity.translate(0, 0, .1),
    this.app.keyboard.isPressed(pc.KEY_S) && this.entity.translate(0, 0, -.1),
    this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
        var e = this.app.assets.find("PlayerLaser").resource.instantiate()
          , a = this.entity.getPosition()
          , s = new pc.Entity;
        this.app.root.addChild(s),
        s.translate(a.x + 1, a.y, a.z),
        s.addChild(e)
    }
}

It looks like you translate it one unit on the X axis after creating the entity so its one unit to the right of whatever entity this script is attached to

It looks like you

Thank you, I tried removing the + 1 and it is still doing the same thing.

So sorry, I thought the link was for the publish project it says I need premium to make it private and I published the project to PlayCanvas so not sure why is isn’t showing that way. (new to PC)

I don’t think you need the translate at all, or you intended it to be moved to be in front of the ship?

Did you mean to entity.setPosition(position.x, position.y, position.z) instead?

Can you provide a link to the project dashboard please so people can look at the project setup and code? Eg https://playcanvas.com/project/438243/overview/orbit-camera

https://playcanvas.com/project/987923/overview/solano_space-project

I would like it to shoot from the ship.

Forked project example: https://playcanvas.com/project/1009137

Main changes:

  • Created an offset from the ship to place the spawned laser
  • Changed the light on the laser to a Omni light as it’s much cheaper than the directional light that was on it
  • Disabled shadows on clustered lights in rendering settings to save startup performance
  • Made the lasers destroy themselves after 5 secs
  • Made the lasers go in the direction they are facing

Wow thank you so much! I updated my original and see a huge difference! Thank you so much! I appreciate your time!