How to constrain a spawn actor onto another spawn actor? (FB)
mitdrissia
Member Posts: 11
Hi guys, i am learning gamesalad.
I have 2 questions.
1. How can i constrain a randomly spawn actor on another spawn actor.To visualize, i want a turret to be on top of a pipe like in mario where you see the bottom pipe with a turret that fires bombs.
2. The turret needs to only fire when the player comes near it. How can i achieve this?
thank you
I have 2 questions.
1. How can i constrain a randomly spawn actor on another spawn actor.To visualize, i want a turret to be on top of a pipe like in mario where you see the bottom pipe with a turret that fires bombs.
2. The turret needs to only fire when the player comes near it. How can i achieve this?
thank you
Answers
If you just have one pipe and one turret spawning at a time, make 2 global attributes. We'll call them... PipeX and PipeY. Inside your pipe prototype, add two constrain attributes - one for PipeX and one for PipeY, constraining the self.position.x and self.position.y of the pipe to them.
You can then use these value to position and constrain your turret. Something like "Constrain attribute self.position.x to game.pipex" and "Constrain attribute self.position.y to game.pipey+50" or whatever.
If you want multiple turrets, you can do that too, but it gets... inelegant. I can try to explain how, but don't want to spend all that time typing unless it's what you need to do How many turrets are you expecting to spawn at any one time?
2. There are a few ways to do this. You might want to read up on the magnitude function. You can also constrain the player's X and Y positions to attributes and use rules to work out if it is greater than or less than the turret's position, and within the "range" of the turret.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
thanks for the fast reply.
I forgot to mention that the bottom pipes also move up and down.
How can i get it to spawn just once in each 10 sec.Also i noticed that when the turret spawns i see it happening.I want the turret to be on the last pipe of the scene so the plane has time to dodge or destroy it with beam.
I allready came this far, hope someone can help me out.
thank you
Is this occuring because i have different spawners?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
You should be able to use the same spawner and have it only spawn the turret every x spawns of the towers.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
As for the random gaps, at some point the gap must be determined. If you spawn your turret between the assigning of that random variable and the generating of the next one, you can still have your turret's initial position correct.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I removed the turret spawner and placed it with the other spawner with a timer of 4.5 sec.
spawn actor turret in front of actor, direction 0 . 0 rel to actor , pos 0 , 0 rel to actor
In actor "goal" (goal of the game is to get between the pipes) i placed spawn actor turret in front of actor, pos 0 rel to actor, self.position.X, self.gap-210 rel to scene.
It works much better, the turrets only pass by every 4.5 sec and they move up when the bottom pipes move up. But they are never exactly on top of the bottom pipes.Sometimes its half above the pipe and half of the turret below the pipe, sometimes the turret is way heigher then the bottom pipe.
Hope we can fix this issue soon
Also a big thanks Armelline who took the time to help me.
I appreciate it