Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → out of bound
out of bound
2001-12-16, 8:20 PM #1
Ok so I'm making this camera cog. Sorta like the saber cam.. I figured out most of it.. but there's still a few things that bother me. First off, the camera is an AttachThingToThing'ed ghost locked on the player. Its POV is made so that if the camera gets moved from its original 'attach' position, it will still point at the player.

Problem is.. If it hits a wall it sorta sticks to it and goes down the z axis slowly.. cause awful HOM when it eventually goes thru the floor or the wall. How can I make it to that it stop at surfaces? AttachFlags perhaps?


------------------
_ _______ _
BladeSinger
Sith Domination (http://www.massassi.net/levels/files/1496.shtml)
BladeSinger

-Are you sure this is the Sci-Fi Convention? It's full of nerds!
2001-12-17, 9:53 AM #2
SetCollideType(camera, 1);
SetThingCollideSize(camera, 0.02);
SetThingMoveSize(camera, 0.02);

These will make your camera HOM free. [http://forums.massassi.net/html/smile.gif]

------------------
-Hell Raiser
Cogging type person that does, umm, stuff.
"Free, your, mind."
-Hell Raiser
2001-12-17, 1:31 PM #3
already tried those and it still gets out of the world. the camera always sorta bumps into the wall for a little bit, but if you bring it further into the wall it jumps thru the wall. thats because I reposition my camera at a set distance behind the player at a pulserate of 0.01 to keep track of the player's movement smoothly. I just don't know how to check if the camera is in the world or if its outside. I guess I could run a GetThingSector(xcam) and check if it returns a -1. But then what? I know its outside, but how do I keep it inside? Is there a KeepThingInSectorOrElseIllGunYouDownToABloddyPulp() verb somewhere? Argh the joy of coding [http://forums.massassi.net/html/wink.gif]


------------------
_ _______ _
BladeSinger
Sith Domination (http://www.massassi.net/levels/files/1496.shtml)
BladeSinger

-Are you sure this is the Sci-Fi Convention? It's full of nerds!
2001-12-17, 2:32 PM #4
sorry, thats not a real verb [http://forums.massassi.net/html/smile.gif]

but you could just temporarly change the camera to a closer ghost cam and keep checking if the other ghost is in a sector, and when it gets back in, change back to it
2001-12-17, 4:07 PM #5
Hell Raiser was trying to do something just like that a few days ago. Look up the posts that were created a few days ago and read HR's post on GetThingSector().

------------------
Incognito
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-12-17, 4:09 PM #6
As you'll read in HR's post, GetThingSector() does NOT return -1 if the thing is not in a sector.

------------------
Incognito
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-12-17, 5:32 PM #7
Bloody buggerin Sith Engine..... *grumbles*

------------------
-Hell Raiser
Cogging type person that does, umm, stuff.
"Free, your, mind."

[This message has been edited by Hell Raiser (edited December 17, 2001).]
-Hell Raiser
2001-12-17, 5:58 PM #8
well, the mod I'm trying to get off the ground has 3 basic camera modes. Stationary, Chase and Dynamic. Stationary Camera is just that, a camera that doesn't move, but follows the player's movement for single-room levels (bosses). Chase Camera is an attached camera. The position of the ghost thing according to the walkplayer position in JED is the distance the camera will be locked at, used for sidescrolling or just general single-direction scrolling. Dynamic Camera works pretty much like the saber camera except that you cannot pitch up or down and the camera's height is passed from the jkl.

Its my first cog ever. I mean, first cog from scratch. I've modified other cogs before but this is the first time I really COGGED something. Anyways, this is what I've come up with so far....

Code:
# Jedi Defender Camera Script rev4c
# Mode 0 = Stationary Camera
# Mode 1 = Chase Camera
# Mode 2 = Floating Camera
# 2001 Jimmy Clark, aka BladeSinger
# random_zak@hotmail.com
# this cog is not supported by LEC
symbols
message      startup                                                          
message      pulse                                                            
thing        player                             local                         
thing        xcam                                                             
int          mode=0                                                           
vector       lookvec                            local                         
vector       campos                             local                         
vector       playerpos                          local                         
vector       lookangle                          local                         
vector       heightadj=(0/0/-0.1)                                             
flex         framelenght=0.01                                                 
end                                                                           
code
startup:
	SetPulse(framelenght);						// Timer
	CycleCamera(1);							// Puts the game in external camera mode
	Return;
pulse:
	GetLocalPlayerThing(player);					// Get the player 
	SetCameraFocus(1, xcam);						// Set external view to camera ghost
	playerpos = GetThingPos(player);					// Get player's position
	if(mode == 1) AttachThingToThing(xcam, player);			// *Chase Camera*
	if(mode == 2)								// *Floating Camera*
	  {									// 
	   lookangle = VectorScale(GetThingLVec(player), 0.2);		// Get player's look vector and scale it down
	   newangle = VectorAdd(lookangle, heightadj);			// Add a little height to the camera
	   campos = VectorSub(playerpos, newangle);			// Determine new camera position
	   SetThingPos(xcam, campos);					// Setting the camera at its new position
	  }
	campos = GetThingPos(xcam);						// Get camera's position
	lookvec = VectorSub(playerpos, campos);				// Determine camera's look vector
	SetThingLook(xcam, lookvec);					// Set the look vector of the camera
	Return;
end


pretty good for a first cog i think, but I still need to figure out a way to keep the damn thing inside the world....

------------------
_ _______ _
BladeSinger
Sith Domination (http://www.massassi.net/levels/files/1496.shtml)

[This message has been edited by BladeSinger (edited December 17, 2001).]
BladeSinger

-Are you sure this is the Sci-Fi Convention? It's full of nerds!
2001-12-17, 6:15 PM #9
Nice bit of cog work there. I've had my fair share of problems keeping the camera inside the world for TDIR. The only thing that works somewhat decently is the "chase camera" that I've come up with that moves, using velocity, the camera to a specified position, and the camera has all the collision stuff in the template so it stays inside the world.
However, it's not to keen in keeping up with turning and running really really fast, and can get stuck in some places. It keeps up with JK speed running (I think force speed too), but the major thing when is you turn, it takes the camera a while to get aligned to behind the player, and strafing is kind of akward. (no matter how fast you move it) It moves fluidly though, and would be really nice for something out there. Here's the jist of it:

Code:
# New Camera Positions
#
# Created by Hell Raiser [Jon Harmon]

symbols

thing		player				local
thing		Camera=-1			local
thing		SCamera=-1			local
int			CamMode=0			local


template	camera_Tpl=+ghost	local
template	camera2=dbzcam	local

vector		Position_Vec		local

message		startup
message		pulse
message		user0
message		user1

end

code

startup:

	player = GetLocalPlayerThing();
	Position_Vec = VectorSet(0.0, -0.1, 0.08);
	SetPulse(0.01);

return;

Pulse:

	//PrintInt(GetCurrentCamera());

	if(Camera != -1) DestroyThing(Camera);

	if(GetCurrentCamera()==1)
	{
		CamMode=CamMode+1;
		if(CamMode > 3) CamMode=0;

		if(CamMode==0)
		{Position_Vec = VectorSet(0.0, -0.1, 0.08);}
		else if(CamMode==1)
		{Position_Vec = VectorSet(0.0, -0.2, 0.1);}
		else if(CamMode==2)
		{Position_Vec = VectorSet(0.0, -0.3, 0.12);}
		else if(CamMode==3)
		{Position_Vec = VectorSet(0.0, -0.4, 0.14);}
		PrintInt(CamMode);
		CycleCamera();
	}

    //if ((jkGetSaberCam() == 1) && (GetCurrentCamera() == 0) && (GetPrimaryFocus(0) == player))
    //CycleCamera();

	Camera = FireProjectile(player, camera_Tpl, -1, -1, Position_Vec, '0 0 0', 0, 0, 0, 0);
	if(SCamera==-1)
	{
		SCamera = FireProjectile(player, camera2, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
		SetCameraFocus(0, SCamera);
	}
	
	SetThingVel(SCamera, VectorScale(VectorSub(GetThingPos(Camera), GetThingPos(SCamera)), 5));
	SetThingLook(SCamera, GetThingLVec(Camera));

return;

user0:
	SetPulse(0);
return;

user1:
	SetPulse(0.01);
return;

end


And the dbzcam template

Code:
dbzcam       none              type=weapon collide=1 move=physics size=0.02 movesize=0.02 typeflags=0x1


Let me explain the template. It's a weapon with typeflags 0x1 so that it doesn't collide with the player, (I know, I'm a genius [http://forums.massassi.net/html/biggrin.gif]) the rest is pretty much self explanitory. The sizes are 0.02 so it doesn't cause HOM. (if the size is small enough, the Actual JK Camera Viewpoint will go outside the world)

The cog always keeps you in 3rd person cuz we (TDIR team) ain't takin the time to make all the keys for a 1st person POV, lol!

I hope this inspires a fix for our problem. [http://forums.massassi.net/html/smile.gif]

------------------
-Hell Raiser
Cogging type person that does, umm, stuff.
"Free, your, mind."

[edit]Dear gawd, I pasted the wrong cog...[/edit]

[This message has been edited by Hell Raiser (edited December 17, 2001).]
-Hell Raiser
2001-12-19, 9:19 AM #10
I had to try making a chase cam. [http://forums.massassi.net/html/smile.gif]

Code:
# Camcog.cog
#
# This cog creates a chase camera that follows the player.
#
# Two safeguards have been added so the camera doesn't get behind a door or something.
#
# [SM]
#==============================================================================#
symbols

message	startup
message	pulse

template	gtemp=ghostcam		local

thing		ghostcam		local
thing		player		local

vector	pos1		local
vector	pos2		local
vector	mvec		local		# Move vector
vector	lvec			local		# Look vector
vector	campos		local

end
#===============================================================================#
code
#--------------------------------------------------------
startup:
	sleep(0.5);
	CycleCamera();
	player=GetLocalPlayerThing();
	ghostcam=CreateThingAtPos(gtemp, GetThingSector(player), GetThingPos(player), '0 0 0');
	SetCameraFocus(1, ghostcam);
	SetPulse(0.01);

Return;
#--------------------------------------------------------
pulse:
	pos1=VectorAdd(GetThingPos(player), VectorSet(0, 0, 0.06));
	pos2=VectorScale(VectorNorm(GetThingLVec(player)), -0.15);
	campos=VectorAdd(pos2, pos1);
	mvec=VectorSub(campos, GetThingPos(ghostcam));
	SetThingVel(ghostcam, VectorScale(mvec, 6));
	lvec=VectorSub(GetThingPos(player), GetThingPos(ghostcam));
	SetThingLook(ghostcam, lvec);
	if(!HasLOS(ghostcam, player)) TeleportThing(ghostcam, player);
	if(VectorDist(GetThingPos(player), GetThingPos(ghostcam)) > 4) TeleportThing(ghostcam, player);

Return;
#--------------------------------------------------------
end


And the template:

Code:
_base		none             orient=(0/0/0) type=weapon collide=1 move=physics size=0.001 movesize=0.001
ghostcam          _base

# Yeah, I know I've got two templates there, but the static.jkl doesn't like just one template (?).


What do you think? Should I submit this?

------------------
Incognito

[This message has been edited by SaberMaster (edited December 19, 2001).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!