More Near more power

mrpacogpmrpacogp Member Posts: 400
edited November 2012 in Working with GS (Mac)
Ok thank you very much the first i have to say, i`m learning alot of things with us.
Now i`m trying for 2 hours how to change something:
max(min(magnitude( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y ),300),0)*2

The original is:
max(0,min(magnitude( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y ),300))*2 (when more near less power)

I want to make more power while more near I'm
But i cant do it!!
I have read it that:http://cookbook.gamesalad.com/question/4e21695fdb04ec688c000019

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You've successfully constrained a value (magnitude) between 0-600. But to increase power as magnitude gets larger, you need something like:

    power=(maxMagnitude-magnitude)/maxMagnitude*powerFactor

    Where maxMaxnitude is 600 and powerFactor is say, 100.

    That takes the percentage distance and multiplies it by a factor.
  • mrpacogpmrpacogp Member Posts: 400
    Like that?
    (600-( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y ))/600*100

    Dont work i think with that or i have missed something
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    Hi @mrpacogp

    You forgot the magnitude expression. Also, a bit more explanation based on info from @tatiang :

    Let's say the maximum power at the centre of the object you get close to is 600. Then you have to decide at what magnitude distance from this point the 0 point is, i.e where the start of adding power is. For an example, lets call that 300. So the power factor in this case, is 2.

    Change Attribute Power to (300-(magnitude(game.Mouse.Position.X-self.Position.X, game.Mouse.Position.Y-self.Position.Y))*2)

    See if that works now.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    Just thought: you need to add, based on the above example, (changing numbers accordingly) a condition when it can start:

    ---make real attribute called Mag

    Rule: When mouse is down
    change (--or-- constrain) attribute Mag to magnitude(game.Mouse.Position.X-self.Position.X, game.Mouse.Position.Y-self.Position.Y)
    Rule: --- nested--- When Mag < 300
    Change Attribute Power to (300-Mag)*2
  • mrpacogpmrpacogp Member Posts: 400
    Ok, that what i need. I have to do a few modify but thank you very much.
    Sometimes we stop on some point for something easy and dont see the light jejeje
    Thank you all people for this support.
Sign In or Register to comment.