I’ve created a factory object in my player, to shoot a bullet at a distance ahead of the player, which works fine. However, when I add animations to this, it first spawns the object from 0/the corner of my map, then travels to the desired distance. Removing the animation seems to allow for the bullet to spawn where I want it, albeit it teleports there rather than animates a path.
I have tried disabling the a sprite until it collides with the player, then re-enabling it, but had no luck.
The code I use has come from the bullet tutorial, which seems to work, and based on what I’ve read, should work, so I am unsure of why the bullet is animating from the corner of the map, rather than the player
if action_id == hash("fire") and action.pressed and ammo>0 then
local pos = go.get_position()
pos.x = pos.x + 50
local rocket_id = factory.create("#rocketfactory",pos)
ammo=ammo-1
go.animate(rocket_id, "position.x", go.PLAYBACK_ONCE_BACKWARD, 1, go.EASING_LINEAR,1)