Hi guys,
I’m incredibly impressed with the new 2D tools, but in the process of switching to the new physics I’ve come across a couple of strange problems.
1) Rigidbody2D interpolation
While my player is jumping, I disable isKinematic, apply a force, and let physics do the work. Under the 3D system, interpolation works great for smoothing out motion between physics steps. Using the 2D Rigidbody with the same settings gives me very strange results -
No matter which interpolation mode I use (interpolate, extrapolate, none) I still get choppy motion. Stranger still is that using interpolate causes the player to travel slower through space (like it’s moving through treacle) and cover less ground, while using extrapolate causes the player to travel faster. The effect is unrelated to the initial jump force or gravity, but it is affected by changing the Fixed Timestep under Project Settings > Time - setting a higher value exaggerates the slow-down/speed-up but even with a really low timestep of 0.001 it’s still noticeable.
Increasing the velocity and position iterations under Project Settings > Physics 2D also has no affect on either the choppiness or the slow motion.
2) Collision contact points
The second problem occurs when using OnCollisionEnter2D() to detect when the player makes contact with the terrain surface after landing a jump. The player has a CircleCollider2D, and the terrain surface is an EdgeCollider2D, created dynamically at runtime.
However, the collision event is being called during the jump, way before any contact is actually made. Debugging the contact points, I can see the collision occurring away from the player’s current position (further along the terrain, where the player has previously been).
The image below shows the player and it’s CircleCollider2D moving from left to right - I’ve paused it after jumping, on the frame where OnCollisionEnter2D() is called. The blue cross is drawn at the contact point (ignore the red / green lines - they’re for visualising a raycast) and the terrain surface is the wavy green line -
Has anyone come across similar issues, or have any ideas what could be causing them?