# [BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

### » Sun Oct 18, 2015 4:55 am

@R0J0hound , post collide only triggers once I think when it first collides, but if the player is standing on the elevator, the elevator would need to continuously negate the forces pushing down on it. I tried anyways, but elevator just gets pushed down.
I also tried the foreach collision pair, and seeing if I could negate forces, but didn't have any success with that.
I've also tried using another object to position the elevator to as a way to keep the elevator from moving, but then it causes objects to sink into it. I assume because it is still getting pushed but the position becomes reset.
:
edit: also, another reason not to use joints is if the elevator must change direction while moving.
B
53
S
24
G
70
Posts: 1,201
Reputation: 41,430

### » Sun Oct 18, 2015 12:18 pm

Thank you @R0J0hound and @Prominent . I'll try and compare both methods, but I think you're probably right and going physics all the way is the best way to go. I'm new to Chipmunk Physics so it's all quite intimidating and I will need to find good tutorials / examples to get started, but if I can get it to work it should help fix a couple of other problems I'm currently facing with my game idea. Thanks again!
B
50
S
20
G
16
Posts: 167
Reputation: 11,972

### » Sun Oct 18, 2015 1:49 pm

@prominent
@waltuo

I posted this a few pages back, might be useful: https://dl.dropboxusercontent.com/u/523 ... pe_v2.capx

The elevator/moving platform thing, i just did that by giving it a high mass & directly setting velocity, there didn't seem to be any problems with deflection on impact, & when it stops moving it's set to immovable.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

### » Sun Oct 18, 2015 2:46 pm

@mattb That looks great and will no doubt help me in understanding how to use physics instead of platform behavior in my project! I will definitely be studying this, thank you!
B
50
S
20
G
16
Posts: 167
Reputation: 11,972

### » Sun Oct 18, 2015 5:30 pm

mattb wrote:The elevator/moving platform thing, i just did that by giving it a high mass & directly setting velocity, there didn't seem to be any problems with deflection on impact, & when it stops moving it's set to immovable.

That method places limitations on what I can do. I'm trying to find a solution that maintains all the physics qualities but can cancel out forces from specific objects.
B
53
S
24
G
70
Posts: 1,201
Reputation: 41,430

### » Sun Oct 18, 2015 7:13 pm

@R0J0hound , I just noticed that if both objects colliding have prevent rotation set to Yes, the collisionImpactX and Y always return 0.
B
53
S
24
G
70
Posts: 1,201
Reputation: 41,430

### » Sun Oct 18, 2015 7:22 pm

@prominent
Here's an idea using collision layers. The idea is the elevator is two different objects on different layers so they don't interact. So for example the orange blocks can affect the elevators motion, whereas the blue one thinks it has high mass.
https://dl.dropboxusercontent.com/u/542 ... ator2.capx

Outside of that idea more of chipmunk's collision handlers would need to be exposed. Then maybe tricks like setting the mass high temporarily before the collision is resolved and then setting it back afterwards could be used.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

### » Sun Oct 18, 2015 8:04 pm

@R0J0hound , ah! thanks. I was able to apply those concepts to my project, and it's working now!
Just curious though if you know, why would the collisionImpactY return 0 if rotations are prevented?
B
53
S
24
G
70
Posts: 1,201
Reputation: 41,430

### » Sun Oct 18, 2015 9:53 pm

@prominent
Not sure. All prevent rotation really does is give the object super high rotational inertia.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

### » Wed Oct 21, 2015 11:26 am

Once again, R0J0Hound dishing out the tasty treats. Thanks for the great behaviour!
B
9
S
2
Posts: 22
Reputation: 626

PreviousNext