Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Rolpa

Top Down Camera Issues?

Recommended Posts

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 Zdoom 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):

//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
#define CAMERA_ANGLE 0.25
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 = CAMERA_ANGLE;  //So the camera doesn't turn with the player.
		int p = 0.25; //The camera's pitch is 90 degrees down.
		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:
actor ChaseCam
{
  height 16
  radius 8
  +NOGRAVITY +NOBLOCKMAP +NOCLIP
  states
  {
  Spawn:
    TNT1 A -1
    stop
  }
}

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×