Top Down Camera Issues

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
Rolpa
Posts: 5
Joined: Sun Jul 24, 2011 11:56 pm

Top Down Camera Issues

Post by Rolpa »

Hello everyone,

I am trying to use ACS to create a top-down camera similar to the one seen in the game MageSlayer. I found a third person camera tutorial on the wiki, and have modified the code in such a way to get a top-down view. I have the camera above the player, and it looks downwards upon the player. However, I have run into a few problems.

The first problem I have is a sprite clipping/billboarding issue. The player sprite does not show up on-screen unless it jumps, or if the camera is blocked by something (which is my next issue.) I have sprite clipping set to xy in my prefernces, and all other sprites (monsters, weapons, etc.) clip properly.

The other issue I have is that the camera will stop following the player under certain conditions. If the player jumps, the camera stops following. The camera also collides with any low hanging ceilings it runs into, despite it's DECORATE actor having the NOCLIP flag.

Once I have dealt with these two issues, this should work without a hitch. I hope you guys can help.

The actual script (note I am using GZDoom, hence 0.25 for the camera's pitch):

Code: Select all

//Top Down Camera Script
//Modified from the the third person camera script by solarsnowfall

#include "zcommon.acs"

#define C_TID		1000	//Default camera tid
#define MAX_R		128	//Maximum radius (or distance from the player)
#define ADJUST_R	8	//Amount to adjust the camera by
#define VIEW_HEIGHT	496.0	//The approximate hight of the player's view

bool cam_mode[8];		//Variable for turning the camera on or off.
	
Script 1 ENTER
{
	cam_mode[PlayerNumber ()] = ON;
	ACS_ExecuteAlways (3, 0, PlayerNumber ());
}

Script 2 RESPAWN
{
	cam_mode[PlayerNumber ()] = ON;
	ACS_ExecuteAlways (3, 0, PlayerNumber ());
}

Script 3 (int p_num)
{
	int r = MAX_R;
	
	while (cam_mode[p_num] == ON)
	{	
		int a = GetActorAngle (0);  //
		int p = 0.25;
		int x = GetActorX (0);
		int y = GetActorY (0);
		int z = GetActorZ (0) + VIEW_HEIGHT;
		int xyr = r * cos (p) >> 16;
		
		if (!ThingCountName ("ChaseCam", C_TID+p_num))
		{
			while (!Spawn ("ChaseCam", x-cos(a)*xyr, y-sin(a)*xyr, z+sin(p)*r, C_TID+p_num, a >> 8) && r > 0)
			{
				r -= ADJUST_R;
				xyr = cos (p) * r >> 16;
			}
			
			if (ThingCountName ("ChaseCam", C_TID + p_num))
				ChangeCamera (C_TID + p_num, 0, 0);
			else
			{
				cam_mode[p_num] = OFF;
				print (s:"Camera script failed to initialize.");
			}
}

else
		{
			while (!SetActorPosition (C_TID+p_num, x-cos(a)*xyr, y-sin(a)*xyr, z+sin(p)*r, 0) && r > 0)
			{
				r -= ADJUST_R;
				xyr = cos (p) * r >> 16;
			}
			
			SetActorAngle (C_TID + p_num, a);
			SetActorPitch (C_TID + p_num, p);
			
			if (r < MAX_R) 
                                r += ADJUST_R;
		}
		
		delay (1);
	}
}

Script 4 DEATH
{
	cam_mode[PlayerNumber ()] = OFF;
	Thing_Remove (C_TID + PlayerNumber ());
}

Script 5 (int p_num) DISCONNECT
{
       cam_mode[p_num] = OFF;
       Thing_Remove (C_TID + p_num);
}

And the Decorate:

Code: Select all

actor ChaseCam
{
  height 16
  radius 8
  +NOGRAVITY +NOBLOCKMAP +NOCLIP
  states
  {
  Spawn:
    TNT1 A -1
    stop
  }
}
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: Top Down Camera Issues

Post by XutaWoo »

Rolpa wrote:The other issue I have is that the camera will stop following the player under certain conditions. If the player jumps, the camera stops following. The camera also collides with any low hanging ceilings it runs into, despite it's DECORATE actor having the NOCLIP flag.
NOCLIP does nothing with SetActorPosition. Your best bet is to just raise the ceiling and keep it level. (not like you're going to see it, anyway)
Rolpa
Posts: 5
Joined: Sun Jul 24, 2011 11:56 pm

Re: Top Down Camera Issues

Post by Rolpa »

I considered that, but this becomes a problem when you go through a door as well.
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: Top Down Camera Issues

Post by XutaWoo »

Well, instead of raising doors, you could use lowering doors instead. Or, if you have the resources, you can use animated doors.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: Top Down Camera Issues

Post by wildweasel »

I see no problem with, instead of archways and other hanging architecture, merely using textures as architecture and thickening it as needed by adding more lines. You could make rooms appear "shorter" by using the ExtraFloorLightOnly stuff (is that what it's called?) to black out the portion of the room that you don't need.
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Top Down Camera Issues

Post by FDARI »

With the latest build of ZDoom you have another way to set position. Decorate function [wiki]A_Warp[/wiki] will allow you to place one actor in relation to another, and choose to ignore placement tests. For the function to work, you should make the player in question a target for the camera. (Can be done by having the player fire the camera, or by recently added ACS functions, among other solutions.)

However, A_Warp as it is today, would be best fit for tracking an actor very rigidly, maintaining always a fixed offset to the player and sharing its interpolation.

I've thought of adding a max distance parameter with options for either failing on greater distances, or (flag) moving up to the maximum distance in the right direction; for a camera that drifts after the player. I haven't tested any of this, though.
Spoiler: Possible solution with existing features
Rolpa
Posts: 5
Joined: Sun Jul 24, 2011 11:56 pm

Re: Top Down Camera Issues

Post by Rolpa »

FDARI wrote:With the latest build of ZDoom you have another way to set position. Decorate function [wiki]A_Warp[/wiki] will allow you to place one actor in relation to another, and choose to ignore placement tests. For the function to work, you should make the player in question a target for the camera. (Can be done by having the player fire the camera, or by recently added ACS functions, among other solutions.)

However, A_Warp as it is today, would be best fit for tracking an actor very rigidly, maintaining always a fixed offset to the player and sharing its interpolation.

I've thought of adding a max distance parameter with options for either failing on greater distances, or (flag) moving up to the maximum distance in the right direction; for a camera that drifts after the player. I haven't tested any of this, though.
Spoiler: Possible solution with existing features
I tried this code, and got an error on startup concerning A_Warp not being defined. I'm assuming this is because I am using GZDoom, which has yet to implement it. I also still cannot for the life of me figure out why the player sprite will not billboard correctly. :?
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: Top Down Camera Issues

Post by wildweasel »

Rolpa wrote:I also still cannot for the life of me figure out why the player sprite will not billboard correctly. :?
Check the OpenGL options under Display Options in the menu.
Rolpa
Posts: 5
Joined: Sun Jul 24, 2011 11:56 pm

Re: Top Down Camera Issues

Post by Rolpa »

I did. Sprite billboarding is set to xy. I messed around with all the other settings but no luck.
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Top Down Camera Issues

Post by FDARI »

Which version of gzdoom are you using? The latest build or the latest release? I think gzdoom is kept fairly close to zdoom.

I'm getting a little closer to being ready to mod for zdoom on my new computer, so that I can work more efficiently at solving this sort of problem, but it is a low priority task.
Rolpa
Posts: 5
Joined: Sun Jul 24, 2011 11:56 pm

Re: Top Down Camera Issues

Post by Rolpa »

I was using the latest release - not the latest build. I downloaded the July 15 build, but it still didn't work.
Locked

Return to “Editing (Archive)”