Page 1 of 1

### Modify position, normal, and depth of collision

Posted: Thu Dec 12, 2013 3:56 am
I noticed some functionality documented in the manual that is not available in the Unity version.

Code: Select all
`cpContactPointSet cpArbiterGetContactPointSet(const cpArbiter *arb)void cpArbiterSetContactPointSet(cpArbiter *arb, cpContactPointSet *set)`

Any plans to expose this? It would be very useful!

### Re: Modify position, normal, and depth of collision

Posted: Wed Dec 18, 2013 3:43 pm
I've thought about it. The problem is that it would require a frustrating large amount of code to pass the cpContactPointSet type back and forth between C and C#. The get functionality is exposed through the other arbiter methods, and the set method is very rarely used.

What did you have in mind to do with it? It's very powerful, but it's also very easy to completely break a the solver with it.

### Re: Modify position, normal, and depth of collision

Posted: Wed Dec 18, 2013 4:52 pm
I'm creating a retro style 2D platformer, and my player is capsule-shaped. Let's say the player is standing on some ground with an angle of 45 degrees. If the player jumps straight up and lands back on the ground, the player's position is shifted slightly because the normal is perpendicular to the ground. I'd like for the normal to always point straight up so that the player will always land directly above the point they penetrated the ground at.

### Re: Modify position, normal, and depth of collision

Posted: Wed Dec 18, 2013 5:17 pm
Unfortunately I think modifying contact points is not very intuitive. If you change the normal to always be upwards, then it will be impossible for the incline to push you in an upward direction and you'll just plow through it. When I've used the feature in the past, I've ended up with some confusing results. (unwanted rotations, surfaces that mush together, etc) Had to sit and think about exactly what it was I was telling the solver with the modified contacts.

I think you might be able to do what you want if you modify the contact points and depth, and reject the collision as appropriate though.

### Re: Modify position, normal, and depth of collision

Posted: Wed Dec 18, 2013 6:30 pm
slembcke wrote:I think you might be able to do what you want if you modify the contact points and depth, and reject the collision as appropriate though.

Are you just saying I should position the player manually using the information from the collision, or is there some functionality you're speaking of that I am unaware of? I thought I'd have to move the player myself if I didn't have access to cpArbiterSetContactPointSet.

### Re: Modify position, normal, and depth of collision

Posted: Thu Dec 19, 2013 11:30 am
Well, I mean if you did have access to cpContactPointSet it might be possible to get the effect that you want, but not as simple as changing the collision normal. I think you are still going to run into issues with walls. While you want the feet to be sampled as a smaller point, you still want the width of the shape to be as wide as the player when standing against walls.

I've always been able to find a happy medium between tweaking the size of a collider and the alignment I want it to have with the graphics, but I'll have to think about this.

### Re: Modify position, normal, and depth of collision

Posted: Sat Dec 21, 2013 1:33 am
I didn't mean I was only going to change the normal. I was just using that as an example because it was the easiest way to explain it. I figured I'd have to modify all three parts of the cpContactPointSet.

I'm not sure what it has to do with walls. I was only going to modify things while the player is standing on ground. If the player jumps into a corner or wall, the regular resolution of the collision should work fine. Also, I wasn't planning on having the "feet" be a separate part of the player. It's just one shape, and it's currently a capsule.