Basic math help needed

tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
edited April 2012 in Working with GS (Mac)
I want to have an actor that constrains self.alpha to a number based on another actor's self.position.y so that if Y is large, alpha is small and if Y is small, alpha is large. For example, if Y is 900 then alpha is .4; if Y is 450 then alpha is .7; if Y is 0 alpha is 1.

My brain is broken. Please help.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Best Answer

Answers

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Just threw this together for you. Is this what your after?

    http://www.mediafire.com/?vprsasx7c9axq3j
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2012
    Awesome help guys, thanks! Each of you gave me a useful demo, but Ace solved the problem with inverted values. It was a simple percentage (distance of the actor from the maximum possible height divided by the maximum possible height), but I couldn't wrap my April Fools' affected mind around. I blame Lego.

    self.alpha=(otheractor.position.y-game.maxY)/(game.minY-game.maxY)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Yep theres many usueally many differnt ways to do thing in gs. By changing the dividing factor in mine you can achieve it at any distance. But @mynameisace used set attributes and fancy colors so this one goes to him :)
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Fancy colours always win... Remember that and you will never lose ;)

    Ace
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yep theres many usueally many differnt ways to do thing in gs. By changing the dividing factor in mine you can achieve it at any distance. But @mynameisace used set attributes and fancy colors so this one goes to him :)
    Well actually I meant that your demo increased the alpha as the actor went higher, whereas ace's demo increased the alpha as the actor went lower (which is what I wanted). Yours is more of a 1:1 ratio and his is a percentage of the total height.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.