Constrain Position to Rotation

IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
edited November -1 in Working with GS (Mac)
Hi everyone!
I have a problem with one thing:
I have two actors in the scene, one of them is rotatable by player (so player can touch it and rotate). It constrains game attribute to actor's rotation.

The second actor is something like indicator on the chart (there's a vertical axis, and the actor is moving on this axis to show the rotation of the main actor).
This actor have a rule:
Constrain Attribute self.position.Y to mentioned above game attribute.
AND
if self.position.Y is bigger than 240.5
then change self.position.Y to 240
AND
if self.position.Y is smaller than 109.5
then change self.position.Y to 110

As you can imagine - it's not working. The indicator actor is just jumping between 240 and 110 (obviously because the game attribute has much bigger values).

Anyone has any idea how to solve it, and make the indicator actor move in Y axis, with rotation of the main actor, but only in specified period? So, when rotation of the main actor is 180, then the indicator actor is in the middle (160 on Y axis), when rotation of the main actor is 359, then the indicator actor is at the bottom etc.? But it has to move instantly with the main actor.

Thank you for your help!

Comments

  • RedlerTechRedlerTech Member Posts: 1,583
    edited December 2016

    Here to save you again ;) You can't change an attribute that is constrained.

    Remember a constrain is doing a change attribute every frame, so you can't change attribute because in a 10 frame period of your attribute equalling

    (Constrained To One)
    1
    1
    1
    1
    1
    4 (Change Attribute)
    1 (Constrained Back Within Only One Frame, Your Change Attribute Is Not Noticeable)
    1
    1
    1

    What you must do, is constrain with min & max functions.

    I don't use these much but I am pretty sure it's gotta be something like

    Constrain self.position.y to max(110,min(240,game.rotationAttributeUWereTalkingAbout))

    Matt :D
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Thanks again Matt :)
  • RedlerTechRedlerTech Member Posts: 1,583
    No probs :D Did it work?
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    NextGen said:
    No probs :D Did it work?

    Nope :P, but I found other way using interpolates :)
  • RedlerTechRedlerTech Member Posts: 1,583
    Hmm that's wierd :/ Should I take another look or you got it covered?
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    NextGen said:
    Hmm that's wierd :/ Should I take another look or you got it covered?

    In your idea, the indicator actor was jumping between two points, as in my idea. But I found a way to go over and make it like this:
    (Rules from indicator):
    If game.XXX is 45
    Interpolate self.Position.Y to 207

    If game.XXX is 0
    Interpolate self.Position.Y to 175

    If game.XXX is 290
    Interpolate self.Position.Y to 110

    Not as perfect as I wish, but it works :P
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    You might try the following two constrains:

    Constrain Attribute: self.size.height To:130-(game.myRotationAttribute*.361111)

    Constrain Attribute: self.position.Y To: 110+(self.Size.Height / 2)

    You would change "myRotationAttribute" to whatever you called it in your game.
Sign In or Register to comment.