Physics (was Events and conditions)

For questions about using Classic.

Post » Sun Apr 26, 2009 3:17 pm

Hi, I have a problem. I think it's due to my limited understanding of Construct.

I want the object to resize when I right click on it. If it's small, it should grow and lose its physics behavior. If it's large, it should become small and gain physical behavior again. And the "small" size is fixed at 32, while the large size depends on the image, and I don't want to lose that size. So here's what I do:


What's wrong here?
B
1
G
4
Posts: 9
Reputation: 1,043

Post » Sun Apr 26, 2009 3:26 pm

What happens when you enlarge it? That is right, its width is not equal to 32 anymore.

Events are processed from top to bottom; after that image width equal to 32, where its size is changed, it then proceeds to the image width NOT equal to 32, which passes as true. So it runs BOTH events within the same cycle.

You probably want to make those two events exclusive; otherwise they both run. Try with "ELSE" condition. Or you could use a variable that is reset at end of the cycle.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Apr 26, 2009 3:32 pm

Yeah! It worked!

But now I have a physical problem... After growing then again shrinking an object, its physics behavior starts acting weird.

It gravitates towards weird directions.

Other objects act weird too.

Is there a solution other than generating a new "large" object on right click and destroying the original, then destroying the large and recreating the small on another right click?

Here, have a cap:
[url:28mjc017]http://www.mediafire.com/file/nnuuz042l54/proj1.cap[/url:28mjc017]
B
1
G
4
Posts: 9
Reputation: 1,043

Post » Sun Apr 26, 2009 5:29 pm

I... have no idea what is going on in that .cap :P

I will say this: Resizing physics objects often leads to bounding box problems. This is a known issue.

What I believe is happening is that the bounding box for your, uh, giant bear macro is glitching out. When you change from large to small, the bounding box is still large, and the small bear macro pushes out of solids away from the black platforms.

What I would recommend is that instead of changing the size of your object, you should destroy your physics object and spawn your larger object in it's place, and vice versa. That way you can preserve your bounding box.

In a future build this probably won't be an issue.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests