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

WeiyuWeiyu Member Posts: 216
edited March 2018 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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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 Member, PRO Posts: 5,364

    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 Member Posts: 465
    edited March 2018

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

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

    @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 Member Posts: 216
    edited March 2018

    @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 Member Posts: 458

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

  • WeiyuWeiyu Member Posts: 216

    @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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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 Member Posts: 216

    @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.