Multiple custom collision objects
TangoDownStudios
Member Posts: 46
Hi! I have an object (lets call it bucket) that spawns walls and a floor for balls to collide with so that it ACTS like a bucket. This "Bucket" actor can move around, but the spawned walls and floor don't move with it!
I know that I can create a global attribute for both the X and Y of the bucket and have the walls follow that value with an offset, but what if I had 7/8 buckets? What if I wanted 30 buckets on screen?!
The problem is is that by using global variables I have to hardcode how many buckets I want in the game : ( That makes me a sad panda. I would also need to hardcode each and every wall and floor to follow a specific bucket.
There would have to be a Bucket1 actor, with a Bucket1LeftWall, Bucket1RightWall, Bucket1Floor and this pattern would continue on for every ... 30+ buckets I want in the game! Making it extremely difficult to expand the game, let alone manage the editor!
How would you all deal with this? How do you make great games in GS without built in functionality for dynamic hierarchies?
I know that I can create a global attribute for both the X and Y of the bucket and have the walls follow that value with an offset, but what if I had 7/8 buckets? What if I wanted 30 buckets on screen?!
The problem is is that by using global variables I have to hardcode how many buckets I want in the game : ( That makes me a sad panda. I would also need to hardcode each and every wall and floor to follow a specific bucket.
There would have to be a Bucket1 actor, with a Bucket1LeftWall, Bucket1RightWall, Bucket1Floor and this pattern would continue on for every ... 30+ buckets I want in the game! Making it extremely difficult to expand the game, let alone manage the editor!
How would you all deal with this? How do you make great games in GS without built in functionality for dynamic hierarchies?
Comments
first I would do a game.Attribute...Index type... call it bucketIndex
create an Actor attribute integer type on the bucket ... call it myIndex#
I assume when you trigger the walls from a bucket... you do so by touch.
Rule when touch is pressed
--changeAttribute game.bucketIndex To self.myIndex#
--ConstrainAttribute game.bucketX To: self.Position.X
--ConstrainAttribute game.bucketY To: self.Position.Y
and any other rules you need... like constrain to touch; spawn walls, etc.
drag the bucket instances to the scene... (they do not have to be in the black area unless you want them all to show up all at once... just trigger their changeAttribute X & Y when you need them)
click on each bucket actor and assign a number to each myIndex# (start with 1 )
(good idea for development purposes put a Display Text [expression] myIndex# on the buckets...)
..
in your wall Actor
bunch of rules
When bucketIndex =1
changeAttribute self.Position.X To: game.X + offset
changeAttribute self.Position.Y To: game.Y + offset
you can just click on that rule hold down and hold down option key and drag it down the page… then change the number for the bucketIndex
this should make spawned wall/ground maintain position even if another bucket is active…
unless you want walls to disappear if bucket is inactive…
then I would NOT spawn them… just drag into the scene 3 instance of the walls and still use this code.
-adding a Rule when bucketIndex = 0 (to send them out of sight…)
-add a Rule to buckets when touch is released change game.bucketIndex To: 0
MH