3rd Person Camera

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
furyweb
Posts: 34
Joined: Thu Aug 30, 2018 3:23 pm
Location: UK

3rd Person Camera

Post by furyweb »

This subject I know has been discussed before, and the problem I noticed is always the crosshair or not having the shooting match the crosshair. I got me thinking. Would it be possible to:

Instead of having your character/sprite being followed by the camera, have a dummy model or sprite that is hidden in the view slightly above the main model/sprite and have the camera follow that instead. Is this possible and if so, would it not solve having the crosshair being obstructed by your model/sprite.

Would be great if you could. I am just curious as I have a few ideas for a 3rd person type mod/game in GZDoom.

Thanks.
Jarewill
 
 
Posts: 1822
Joined: Sun Jul 21, 2019 8:54 am

Re: 3rd Person Camera

Post by Jarewill »

I am not sure I understand what you are asking for.

That being said, the basic idea behind a 3rd person camera is to spawn an actor to serve as a camera, set the player's camera to that actor using SetCamera for ZScript or ChangeCamera for ACS and then use Warp, either the ZScript or ACS variant, every tic to move the actor into proper position.
Here's a quickly made example:

Code: Select all

Class CameraPlayer : DoomPlayer{
	Actor cam; //Save the camera actor to a pointer
	Override void Tick(){
		Super.Tick();
		If(!cam){cam = Spawn("BackCamera");} //Spawn the camera if it doesn't exist
		SetCamera(cam); //Set the player's camera to the camera actor
		cam.Warp(self,-64*cos(pitch),0,height/2+64*sin(pitch),0,WARPF_NOCHECKPOSITION|WARPF_COPYPITCH|WARPF_INTERPOLATE); //Move the camera actor into position
	}
}
Class BackCamera : Actor{
	Default{+NOGRAVITY; +NOBLOCKMAP;}
}
If this code isn't what you were asking for, then please elaborate further.
User avatar
furyweb
Posts: 34
Joined: Thu Aug 30, 2018 3:23 pm
Location: UK

Re: 3rd Person Camera

Post by furyweb »

K so here are 2 pictures, top one is how it is using ZSC Chasecam mod with precise crosshair. As you can see it has the crosshair slap bang in the middle of the sprite. The second image is edited in Photoshop to show what I am trying to achieve.

https://i.imgur.com/f9zROYt.png

https://i.imgur.com/5rfxz5c.png

Thanks!.
Jarewill
 
 
Posts: 1822
Joined: Sun Jul 21, 2019 8:54 am

Re: 3rd Person Camera

Post by Jarewill »

I am not sure what ZSC Chasecam mod you are speaking of, but you will have to open it and edit relevant lines to make the camera higher while following the player.
Usually that would be done by raising the Z offset if it's using Warp, but I don't know if it does use it.

Return to “Scripting”