Keep Object From Moving on Y Axis (Random Y position)
joaosjc
Member Posts: 19
I'm creating an endless runner illustrate in the image bellow:
The buildings spawn in a random y position and has a move rule for the x axis.
The problem I'm having is that whenever the character lands on the building, the building moves down.
I've already tried marking the fixed rotation, change the drag and density attributes, but none of them work.
The last try was to create the following rule to my buildings:
Change attribute -> game.yposition to self.yposition
constrain attribute -> self.yposition to game.yposition
It doesn't work because every time a building is spawned it changes all the other buildings y position.
I know you guys will help me out with this.
Cheers.
Comments
easy way, did you try constraining self position to self position.
To clarify, that would be Constrain Attribute self.Position.Y to self.Position.Y. As you noticed, you can't use a single game attribute for multiple attribute values. But you can constrain an attribute to itself in order to force it to not change.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Create a real attribute within the building actor. Call it "MyY".
Add the following statement to the building actor.
Change attribute self.MyY to self.posY
Make another rule,
If self.posY < self.MyY
constrain attribute self.posY to self.MyY
I tried this too!! Didn't work
It seems that it if there is another event that changes the actor y position, this code does not have the power to prevent it from moving.
Can you post a screenshot of your actual rules?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Everything Rabid Parrot said except the last bit I would not have the rule just the constrain attribute self.posY to self.MyY and make sure the building actor has fixed rotation. If they are all self attributes it should work.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
don't use constrain. just set the Y value when the object is spawned with a change attribute. change the y value just before you spawn. it's that easy.
Hi @joaosjc also try unchecking Moveable for your spawned buildings.
Lovely graphics, BTW.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Actually, it worked. Tks. I was creating the "Y" attribute in the game. Haven't though about creating it in the actor. After I created the attribute myY, changed it to the spawn moment y position, and constrain the character position to it, it worked. Many tks
tks