Chase Camera and Inbuilt Physics

rated by 0 users
This post has 15 Replies | 5 Followers

Top 10 Contributor
Posts 513
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee
DSebJ Posted: 12-22-2011 7:02 PM

Has any one else tried attaching a chase camera to an object affected by the inbuilt physics system?

I am getting some really weird results - It's flickering all over the place and make the object look like it's in multiple locations at the same time. When I tried to record this behaviour with Expression Blend Screen Recorder, it all of a sudden worked perfectly - then when I hit stop it went back to the same behaviour. 

If I just transport the object directly, by updating it's world matrix with a new location then the chase camera doesn't have a problem and is very smooth.

Any ideas?

Top 50 Contributor
Posts 134
SunBurn_Community_Licensee

Was it flickering vertically? I was doing something similar and had flickering up and down, I think it was to do with the update order of things, perhaps the object was falling for a frame with Sunburn and being snapped back into position by my chase cam stuff. I moved where I update my chase cam so Sunburn has updated the object first and it fixed it. Now I read the Sunburn matrix, modify it to move and then write it back and it seems to be working better. Don't know if it's the same issue...

Top 10 Contributor
Posts 513
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

Could be.

I've ported the chase camera sample on creaters.xna.com to be a SunBurn component, with the idea that you just attach it to the object you want to follow, attach the movement controls component and then your done for the player movement, view etc.

But it's only an issue with the inbuilt physics. If I build the player movmeent control with the updates to directly move the player I don't get the flickering - it only happens when the physics are moving the player.

Could be the order that the physics is being called, before the chase camera but I don't have a way to control when the update to the component is called or in what order.

Where you using the physics inbuilt or some other physics library?

 

Top 50 Contributor
Posts 134
SunBurn_Community_Licensee

I was just experimenting with the inbuilt physics - I just want to push a sphere around that represents a player and have it collide. I was getting the world matrix, modifying it and writing it back but you can push the object through walls then because it's not respecting the results of the collisions. I'm just experimenting with ApplyWorldForce at the moment, not sure how that will turn out yet.

Top 10 Contributor
Posts 513
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

I've got a sample component you could have a look at: http://dsebj.evolvingsoftware.com/?p=199

Player movement with the inbuilt physics was one of the first things I got started with too :-)

Top 50 Contributor
Posts 134
SunBurn_Community_Licensee

Thanks! I'll check it out.

Top 500 Contributor
Posts 6
SunBurn_Pro_Licensee

I accidentally edited my previously putting what I wanted to reply lol sorry...

Top 10 Contributor
Posts 513
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

If you don't need the lerping from the chase camera; you can just use a fixed position offset.

Have you tried changing the offset values where the camera is being placed?

Top 500 Contributor
Posts 6
SunBurn_Pro_Licensee

Yup, I did worked with the camera offset variable and still the camera shows always pointing down to the player and not as the picture I show you here :L

when I see the quaternion and the lerp I become a derp (lol) and feel like going home ;D, so I got confusion with that ;l

 

I am still working with it to make it look at the picture :i

Thanks for the reply :)

Top 25 Contributor
Posts 186
SunBurn_Community_Licensee

DSebJ , did you find a solution to this ? 

Top 25 Contributor
Posts 186
SunBurn_Community_Licensee

Actually, I also have a chase camera which follows my SceneObject quite well if not used Physics.. 

But if I use:

            if (CollisionMove != null)

            {

                CollisionMove.ApplyWorldForce(World.Forward * 1f, false);

            }

My chase camera start falling back and jittering... I update my camera as follows :

                chaseCamera.ChaseDirection = target.World.Forward;

                chaseCamera.ChasePosition = target.World.Translation;

                chaseCamera.Up = target.World.Up;

I guess after applying Physics there should be an order of getting current World afterwards... Maybe it should be set in Physicsmanager order ?

Anybody has any ideas ?

Top 25 Contributor
Posts 186
SunBurn_Community_Licensee

I assume the target.World.Translation has the problem but donno why..

Top 10 Contributor
Posts 513
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

Are you updating this in the update method of the main game class or a manager class?

Or is this logic in a component?

I experienced a similar issue when using components. I move my camera update logic in to the main game update method and removed the issue. Although I think the reason for why this was an issue has been resolved in a subsequent release but I haven't gone back and checked and tested it. 

For trouble shooting (only! Before any one calls me up about it :-), try putting the camera update logic at the begining of the draw method and see if that resolves the issue. 

Cherrs

Sebastian

 

Top 25 Contributor
Posts 186
SunBurn_Community_Licensee

I have no idea but that resolved the issue ... I put the camera update into the beginning of the Draw method (which is awkward) and the jittering is gone for the moment.. I will check more why this could have happened... (eyes rolling to John)

Thanks u a lot DsebJ!

Ciao

CS

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi cemal,

Make sure to sync the camera and object position after SceneInterface.Update() is called (or specifically the contained PhysicsManager.Update()).  This ensures the camera and target object are always in sync with each other.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Page 1 of 2 (16 items) 1 2 Next > | RSS