Creating a laser

edited March 2012 in Help request
We're trying to make a laser that follows the player. How would you make something like that?

I thought it would be that you would make the spawner the parent of the bullets, and the bullets would follow the spawner attached to the player. However, this has not worked for us. It almost seems as if the spawner is offset horribly at twice the distance from the player it should be. Our player spawns at 512,512,80 and the spawner's bullets shoot at 1024,1024,160. However, the bullets still move with the player. Here is the code:
;ShipBase.ini
[Ship] ; Object
Graphic          = ShipGraphic
Position         = (512.0, 512.0, 80.0)
Body 			 = ShipBody
Type = "Ship"

[ShipGraphic]
pivot = center
TextureSize = (24, 26, 0)
TextureCorner = (48, 0, 0)


[ShipGraphic]
Texture = ../Gameplay/Characters/Laser/Laser.png
Pivot   = center

;ShotBase.ini
[Shot] ; Object
Type			 = "Shot"
Graphic          = ShotGraphic
Color            = (255, 255, 0) # (0, 255, 0) # (255, 0, 255) # (0, 255, 255)
Scale            = (2.0, 2.0, 0) ; NB: z is ignored for 2D objects
BlendMode        = add
Speed            = (100, 0, 0)
Body             = ShotBody
UseParentSpace   = true

[ShotGraphic] ; Graphics
Texture = ../Gameplay/Characters/Shot.png
Pivot   = center

;Laser.ini
[Ship]
Spawner = RedSpawner

[Shot]
UseParentSpace = true

[RedSpawner] ; Spawner
Object = Shot
WaveSize = 3
WaveDelay = 0.0
ObjectSpeed = (0,-500,0)
UseSelfAsParent = true ;NB: If set to true, the created object's parent will be the spawner. Defaults to false;
ShotDamage = 1

By the way, the spawner is in the right place; the bullets are spawned by the spawner in the wrong place.

Comments

  • edited March 2012
    Hi!

    There's been a thread on this issue: using spawner parenting with objects that have a physics body.

    It's a bug in orx that has been solved a month ago.

    To verify it's the same issue, remove the body from your laser and if it follows correctly your spawner that means it was the bug I fixed.
Sign In or Register to comment.