Game glitches with apparently no reason (interpolation behavior)

Wonder MaruWonder Maru Member, PRO Posts: 98
edited February 2016 in Tech Support

Hello everyone,
I started with GameSalad recently and so far I was enjoying the experience (despite the lack of some basic features), but yesterday I've got into a bug/glitch that I cannot explain and for which I couldn't find an answer here or anywhere online.

I'll try to provide a video capture later, but the thing is pretty easy:

I have an actor that should move left and right on the screen, while moving from the top of the screen to the bottom of a certain amount of pixel when the screen is tapped. The horizontal left right movement is automatic and smooth, while the vertical descent is by steps when I tap the screen.

I can't set colliders on the edges of the screen to make it change direction, since I want this to be like a block I can use to make custom obstacles, all with the same movement, and I don't want each block to go all the way to the edges every time. Basically I need these blocks to create walls with custom gaps for the character to go through.

So I gave this actor an interpolation. I read its X position as first thing, I set an attribute to be equal to this initial position.

Then, in an rule where I check if the actor is still on screen, I interpolate the actor X position to something like "original X" + 100. And it moves right. Perfect.

In the same rule I check if the actor X is in the "original X"+100 position, if so it means it moved, and then I send it back to "original X".

It worked fine, and with ease in/out was looking pretty smooth.

But then I realized I was moving the actor just back and forth in one direction, while I'd need an equal movement left and right from the original spawning position.

And here comes the problem.

I set a boolean attribute called "moved_rt" (moved right) to check if the movement to the right was done, set to FALSE.

All in the same rule (the one checking the actor to be on screen) I then checked if the actor X was equal to "original X" AND "moved_rt" is FALSE, then interpolate to self.x+100.

If self.X is equal to "original X"+100 then interpolate self.x to "original X" and change attribute "moved_rt" to TRUE.

Then if self.X = "original X" AND "moved_rt" is TRUE, interpolate self.X to "original X"-100.

Last if self.X = "original X"-100, interpolate self.x to "original X" and change attribute "moved_rt" to FALSE.

Makes sense, right? Writing it down now just convinces me more that the logic is working.

The problem? When I add these modifications to the rule and I click play to test it, the game area glitches with portions of the gamesalad window messed up inside the preview area (you know the typical screen glitches where various parts of what's on screen are mixed up in random pixels? That). After this glitch, during a couple of seconds, the actors move on screen in a very glitchy way, lagging, moving too fast skipping frames etc... Like a memory issue, maybe?
If I try to test it with the iphone preview app, the app crashes.

The funny part is, if I try to go back removing the new things, the game still do that thing. Luckily I saved a copy on another file and every time I test this I make a new copy. But this is pretty weird, right? Any idea?

Thanks so much to anyone who will try to help me with this.

Wonder Maru: casual games for casual people. www.wondermaru.com

Comments

  • Wonder MaruWonder Maru Member, PRO Posts: 98

    Note:

    if there's a better way to make an actor goes back and forth of a certain amount of pixels regardless the place it gets spawned, I'm very happy to try it :)

    Wonder Maru: casual games for casual people. www.wondermaru.com

  • IceboxIcebox Member Posts: 1,485
    edited February 2016

    @TokyoCandies said:
    Note:

    if there's a better way to make an actor goes back and forth of a certain amount of pixels regardless the place it gets spawned, I'm very happy to try it :)

    Create 3 real attributes name them Center X , distance , speed.

    1- place a change attribute , change attribute center x to self.position x

    2- place a constrain attribute
    constrain self.position x to Self.Distance * cos (Self.Speed * Self.time)+ Self.centerX

    Put the actor on screen and put a value in distance and speed , it will make the actor go right and left based on the value of distance , at the speed you want . If you want to control the Y position just replace position x with y and change cos to sin , you can also have both together , having both x and y with the same speed will give you a circular movement. You can play with the numbers to get the result your looking for and you can also tick off " moveable " .

    Hope this helps

  • Wonder MaruWonder Maru Member, PRO Posts: 98

    @Icebox1910 said:

    @TokyoCandies said:
    Note:

    if there's a better way to make an actor goes back and forth of a certain amount of pixels regardless the place it gets spawned, I'm very happy to try it :)

    Create 3 real attributes name them Center X , distance , speed.

    1- place a change attribute , change attribute center x to self.position x

    2- place a constrain attribute
    constrain self.position x to Self.Distance * cos (Self.Speed * Self.time)+ Self.centerX

    Put the actor on screen and put a value in distance and speed , it will make the actor go right and left based on the value of distance , at the speed you want . If you want to control the Y position just replace position x with y and change cos to sin , you can also have both together , having both x and y with the same speed will give you a circular movement. You can play with the numbers to get the result your looking for and you can also tick off " moveable " .

    Hope this helps

    this sounds great!
    Didn't think to use cos or sin. Will try as soon as I get home and let you know if this works for my project!

    Thank you!!!

    Wonder Maru: casual games for casual people. www.wondermaru.com

  • Wonder MaruWonder Maru Member, PRO Posts: 98

    I'm gonna try the solution suggested, but just for complete information, in case anyone else had/will have the same issue, here is what happens.

    And this is the piece of code that makes the mess if I try to change it. As you can see there is a +100 in the interpolation behaviors. That was originally +40. Just by changing that value the glitch happens. And even going back to 40 (not that this makes any sense though) the glitch persists and the file is gone forever. If I open the previous version, with +40, it runs ok...

    Wonder Maru: casual games for casual people. www.wondermaru.com

  • Wonder MaruWonder Maru Member, PRO Posts: 98
    edited February 2016

    It works GREAT!
    At first seemed like it didn't cause I set a very low speed and I couldn't even notice the movement :P

    That's great! Thank you so much!

    Also, this made me learn about the "time" attribute that I wasn't aware about and I think it will be very useful!

    Again: thanks!

    Wonder Maru: casual games for casual people. www.wondermaru.com

  • IceboxIcebox Member Posts: 1,485

    @TokyoCandies I dont know why it never happened to me , can you try the same method on a new actor ? and see if it works ?

  • Wonder MaruWonder Maru Member, PRO Posts: 98

    yes, good idea. I'll try the same thing in a new project, with just those rules and see if that still happen.

    Anyway your solution works perfectly :thumbup:

    Wonder Maru: casual games for casual people. www.wondermaru.com

  • RadiationYTCRadiationYTC Member Posts: 5

    You have to have lowercase change attribute to false and the same goes to true, if you have it in capital it seems to not do anything and crash.

Sign In or Register to comment.