GameSalad

【Trouble】The actor will disappear when actor'size interpolate to negative.

WeiyuWeiyu Posts: 201Member, PRO
edited March 6 in Working with GS (Mac)

Hello everyone.I meet a big trouble.

The actor will disappear when actor'size interpolate to negative.

  • My behaviors:
  • interpolate "self.width" to "-100"

I don't know why it happened.
Please help me. Thank you.!

Comments

  • tatiangtatiang Posts: 11,297Member, Sous Chef, PRO, Senior Sous-Chef

    It happened because an actor can't have a width of -100. What did you want to have happen when it's width reached negative one hundred?

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

  • ArmellineArmelline Posts: 4,590Member, PRO

    The interpolate kind of "overrides" the actor's width all the way up to -100. Once the interpolate finishes, the actor goes "Now my width is -100! Wait, I can't be negative width. The smallest width I can have is 0. Best set myself to 0 then."

    You can get around this by just interpolating the width to 0, then back to 100. Same effect as far as the user is concerned.

  • RowdyPantsRowdyPants Posts: 381Member, PRO
    edited March 7

    @Weiyu You're setting the width here - not just subtracting 100 from the width. So just set it to 0.

  • tatiangtatiang Posts: 11,297Member, Sous Chef, PRO, Senior Sous-Chef

    @RowdyPants said:
    @Weiyu You're setting the width here - not just subtracting 100 from the width. So just set it to 0.

    Ah, I think you're right... she/he may not have understood how Interpolate works. Interpolate changes the value of an attribute from it's current value to a final value (in this case, -100) over a time period.

    If you want to Interpolate from the actor's current width to a value one hundred less than that, you would do it this way:

    Change Attribute self.NewWidth to self.Size.Width-100
    Interpolate Attribute self.Size.Width to self.NewWidth

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

  • WeiyuWeiyu Posts: 201Member, PRO
    edited March 7

    @Armelline @RowdyPants @tatiang

    Thank you for your reply.
    I'm not have understood how Interpolate works that I was wrong.Sorry. :'(

    I want actor to negative gradual elongation.

    This is my original behaviors:


    1. Constrain Attribute
      constrain "self.position.x" to "80+(self.size.width/2)"

    2. Constrain Attribute
      constrain "self.size.width" to "game.time*64"


    I was going to use "Constrain Attribute" to gradual elongation, but it only positive elongation. So I tried use Interpolate to do it, but It couldn't come up with negative elongation all along. :'(

  • Twayne2Twayne2 Posts: 157Member, PRO

    Interpolate self.width to self.width + 400. That should work. :smile:

  • WeiyuWeiyu Posts: 201Member, PRO

    @Twayne2 said:
    Interpolate self.width to self.width + 400. That should work. :smile:

    Thank you for your reply. :)
    But that still can't work what I want to do.

    I hope actor can negative elongation, not positive elongation.
    I have no idea how to let actor negative elongation...

    Just like this:

  • tatiangtatiang Posts: 11,297Member, Sous Chef, PRO, Senior Sous-Chef

    Change the plus to a minus:

    constrain "self.position.x" to "80-(self.size.width/2)"

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

  • WeiyuWeiyu Posts: 201Member, PRO

    @tatiang said:
    Change the plus to a minus:

    constrain "self.position.x" to "80-(self.size.width/2)"

    This is amazing!!! The problem worried me for long time.
    I can't believe my eyes, this is so easy.
    I really appreciate it. Thank you for your help again. :D

Sign In or Register to comment.