Constrain Actor to Spawned Floor
JackSoft
Member Posts: 27
I hate to ask this because I feel like ill get the stock "RTFM" or "Search is your friend" replies. But so you know, ive read the manual, watched the cookbook vids, as well as a bunch of other vids and can't seem to figure this out.
Im spawning a floor in a runner game. The floor is spawning on random Y coordinates between a set range. My idea was that I can set a game attribute that is equal to the spawned floor Y coordinate. Then, constrain my hero to that Y coordinate and add half the height of the floor so that the bottom of my hero lands on top of the floor rather than centered. This is something:
Hero
constrain
self.PositionY to game.FloorY + 10
Thats all good. But, my hero is on the left side of the scene and the floor is being spawned on the right side. So the hero isnt lining up with the floor that is directly beneath it. I know its probably something simple here. Maybe I dont need to constrain at all, and I need to use gravity somehow.
Thanks for any help in advance.
Im spawning a floor in a runner game. The floor is spawning on random Y coordinates between a set range. My idea was that I can set a game attribute that is equal to the spawned floor Y coordinate. Then, constrain my hero to that Y coordinate and add half the height of the floor so that the bottom of my hero lands on top of the floor rather than centered. This is something:
Hero
constrain
self.PositionY to game.FloorY + 10
Thats all good. But, my hero is on the left side of the scene and the floor is being spawned on the right side. So the hero isnt lining up with the floor that is directly beneath it. I know its probably something simple here. Maybe I dont need to constrain at all, and I need to use gravity somehow.
Thanks for any help in advance.
Answers
Hi @Jack Soft
One way would be to put the random x of the floor chosen into an attribute as well, and change the position x of your Hero to match (if you wanted him smack bang in the middle of the floor - if not, simply change his x pos. to that of the floor x minus just under half of the width of the floor to get him on the left, for instance).
Another point: the game.FloorY (and now game.FloorX as well) is good to be constrained to coordinates that are randomly set, but there's no need to constrain the Hero's position, just use a Change Attribute there.
So:
Hero
Change Attribute self.PositionY to game.FloorY + 10
Change Attribute self.PositionX to game.FloorX - 100 (as an example)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps