what expression should I try?

GhostShipAppsGhostShipApps Member Posts: 81
Hi all, I've a little question here.
I have an attribute called "GremlinsVsSanta" that goes random from 0 to one million (999,999 to be exact)
I need to constrain the position of an actor to the top of the screen (768) when "GremlinsVsSanta" equals cero, and to the bottom of it when "GremlinsVsSanta" is one million.
Any help is really appreciated. THanks.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @GhostShipApps

    Hi! You'd use the random expression in the Expression Editor:

    Change Attribute GremlinsVsSanta to random(0,1000000)
    ----no need for a constrain in this case as the number is fixed
    When GremlinsVsSanta = 0
    Change Attribute self.YourActor.Position.Y to 0

    When GremlinsVsSanta = 1000000
    Change Attribute self.YourActor.Position.Y to 768

    BUT....... that's a really big but..... you'll not see your actor move to zero or 768 within... a year? Two years or more? Don't know.... I do know though the chances of the random number 0 or 1000000 picked out of 1000001 numbers is very high....

    I'd suggest a much lower number than 10000000; even with 1000 you'll be waiting a very long time for 0 or 1000 to turn up; and even if one of those, by chance did appear in the first half an hour, you'll not see them again for quite a while.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • GhostShipAppsGhostShipApps Member Posts: 81
    @gyroscope

    Thank you.
    You are totally right and can be solved that way, but at the same time I am trying to learn how to do inverse proportion in the expression editor. Basically to make an attribute increase or decrease in the opposite direction of the other... The smaller attribute A is, the bigger attribute B gets.
    If you or anyone knows a good link for this would be awesome. Thanks!

  • simo103simo103 Member, PRO Posts: 1,331
    @GhostShipApps ... I would think that if you wanted an exact change in B related to A then have Attribute OLDA and NEWA and make b=b+(OLDA-NEWA) so for example.
    OLDA=10 NEWA=8 b=20 .... after the change NEWA=8 b=22.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Got it, OK, if you know at least one of the actor's rate in one direction, you can calculate it for the other actor to match the rate in the opposite direction....

    First though, a couple of questions to you and fingers crossed I could sort out a solution... what method are you using to move your actors: velocity, acceleration, interpolate, move to? And does the actor's speed which you want to match to vary over time?



    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • GhostShipAppsGhostShipApps Member Posts: 81
    thanks #gyroscope , this is the situation:
    Based on a series of puzzles you will get your score. Best score is 1 and the worst performing is 999,999.
    If you scored very bad, lets say 800,000, your little Santa will appear at the bottom, if you are number 1 will be at the top.
    I already solved it constraining the height of an invisible actor to the score divided by a variable that depends on the same score. Then I just make the little actor collide with the invisible. THanks again.
Sign In or Register to comment.