GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Change size upon collision

I'm trying to make it so that when the main actor collides with another actor called a Deflator, the main actor shrinks in size to a certain degree. However, I tried adding the Rule to the main actor that whenever it "overlaps or collides with" the Deflator, it would "Change Size" to -50 but that didn't work. Then, I removed the "Change Size" behavior and replaced it with "Change Attribute", where I set self.size.width to -200, which also didn't work. Then in Change Attribute, I set self.size.width to self.size.width-200 which also did not work.

What am I doing wrong here?

Comments

  • SLOCM3ZSLOCM3Z Posts: 796Member

    Make a game attribute and call it Deflate. Make a rule that says: when collides with: deflator, :do: change attribute game.Deflate :to: true. Then make ANOTHER rule that says: if game.Deflate = true :do: change attribute size.Width or Height :to: (desired number).

  • hamzawesomehamzawesome Posts: 30Member, PRO

    @jdlcrater said:
    Make a game attribute and call it Deflate. Make a rule that says: when collides with: deflator, :do: change attribute game.Deflate :to: true. Then make ANOTHER rule that says: if game.Deflate = true :do: change attribute size.Width or Height :to: (desired number).

    I followed all of those steps and that didn't seem to work either. Why do you think Change Size doesn't work? Such a behavior sounds simple enough...

  • GnarlyGnarly canadaPosts: 840Member

    Let's say your main actor is 100 width and 200 wide.

    Could make rule in main actor.

    If main actor collides with deflator.
    Interpolate self.width to 50

    Interpolate self.width height to 100.

    This will shrink your main actor in half.

  • hamzawesomehamzawesome Posts: 30Member, PRO

    @gattoman said:

    Let's say your main actor is 100 width and 200 wide.

    Could make rule in main actor.

    If main actor collides with deflator.
    Interpolate self.width to 50

    Interpolate self.width height to 100.

    This will shrink your main actor in half.

    Unfortunately, I just tried this, but it also didn't work. I appreciate the help though!

  • SocksSocks London, UK.Posts: 12,822Member
    edited October 2015

    //

  • GnarlyGnarly canadaPosts: 840Member

    Methods given do work. So your implementation is incorrect or your expectations are unclear.

    Even your first post almost works. I'm guessing changing attribute -200 may be your problem.

    You can't have a - negative width or height. So - 200 wont work. Unless it's a math equation that would work.

    You have to give more details. What happens when you tried it? Etc Show us the work. This is very easy to do. Just have to supply info.

  • GnarlyGnarly canadaPosts: 840Member

    You could also

    in main actor
    If main actor collides or overlaps with deflator

    Timer behaviour : FOR 2 seconds
    change size behaviour -.2

    this will work but very slowly shrinking.......

  • SLOCM3ZSLOCM3Z Posts: 796Member

    All the methods we have shown you work. Show us a screenshot of your rules and we could probably see what MIGHT be the problem... Otherwise... I don't know :)

  • myke66myke66 Posts: 70Member, PRO

    Collision detection stops working for some reason when using the Change Size function, you're not crazy.

    To do what you want, what i've done is created a rule that kicks off your resize and have a timer loop +/- to the height/width of the actor until its where you want.

    RULE: If -> Collide with ActorX
    Timer: FOR 2s
    { Timer: EVERY 0.5s
    {
    (change self.height to self.height+1
    change self.width to self.width+1)
    }
    }

    Im sure there are more optimized ways of doing it without the timers or by using the game clock, but basically if you want to keep collision detection on an actor that is scaling, you need to do it incrementally.

Sign In or Register to comment.