GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Position constraint problem

ZourathZourath Posts: 16Member
edited November -1 in Tech Support
It appears that when I constrain the Y position, the X position gets stuck. For example, this actor is supposed to move left and right, and always be constrained to a certain height, but when it gets its height location variable constrained, it cannot move left or right.

Comments

  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    Which behaviors did you use for movement?
  • ZourathZourath Posts: 16Member
    The move behavior.
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    I'll look out for it, but I haven't been able to reproduce it.
    Do you have both move behavior Move Types set to stacked? If it is set to additive and you push both directional keys at the same time, then they may cancel each other out.

    Here is what I have:
    1. Create an actor.
    2. Add the Constrain Attribute behavior and set the Y position (self.Position.Y) to 160.
    3. Add a rule that activates with the condition, Actor receives event > key > left > is down.
    4. Add a Move behavior within that rule with Direction 180. Move Type: stacked
    5. Add a rule that activates with the condition, Actor receives event > key > right > is down.
    6. Add a Move behavior within that rule with Direction 0. Move Type: stacked
  • ZourathZourath Posts: 16Member
    How odd. That is basically how mine is set up, the only differences are the Y position is set to 30, not 160, keys a and d replace left and right, and a few other key checks which shouldn't interact with this code, and it doesn't work. That said, I found a fix. I removed the constraint and added a rule that checks to see if the Y position does not equal 30. If it doesn't then it changes the Y position attribute to 30.
This discussion has been closed.