Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by 7th_zorro. 04/20/24 07:29
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, henrybane, flink, Edgar_Herrera), 758 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! #220738
08/09/08 00:57
08/09/08 00:57
Joined: Aug 2008
Posts: 61
Neurosys Offline OP
Junior Member
Neurosys  Offline OP
Junior Member

Joined: Aug 2008
Posts: 61
ok.. this whole app works fine. menus, panels, world setup..eveything... in startworld() we hide the PANELS since we are done with the main menu at that point.

We also do this in startworld():
Code:
	while(player == NULL) { wait(1); }
	player.x = 570;
	player.y = -1996;
	player.z = 330;
	player.pan = 323;
   vec_set(camera.x,vector(-180,0,50));
	vec_rotate(camera.x,player.pan);
	vec_add(camera.x,player.x);
	camera.pan = player.pan;
	camera.tilt = -15;


That lines up the camera PERFECTLY behind the player in a third person cam type arrangement (above and behind). Now the thing is in the AUM61 code I got the vec_set thing from the player action enters a while(1) wait(1) of course and handles his movement and gravity. again.. works like a dream.. however.. when we place those 3 magic vec_??? lines from startworld():
Code:
vec_set(camera.x,vector(-180,0,50));
	vec_rotate(camera.x,player.pan);
	vec_add(camera.x,player.x);


which should (AND DO) keep the camera at its perfect 3rd person cam alignment. Thing is when I do this in the player action (or even the main loop instead) or anywhere that updates it constantly i get grey(my sky.tga color actually) flickering... so I figure the camera is going apeshit and I hit F11... bingo.. the cam is flickering thru two or more x,y,z positions and I realize the camera is being set to the vector (1 position move) rotated to match up with pan (2 moves) and added to player vector (3 moves) so I do what anyone would do and make a tempvar and do all the calcs on it behind the scenes then once I got the resulting vector copying it straight to camera vector with vec_set(camera.x,tempvar.x) well.. it works... but it still flickers!!! grr!! which is really wierd cuz in that scenario is like "wtf else is moving the cam then?" anywho.. here is the whole code and I'll totally sex0r anyone who can figure it out.

Code:
//include <default.fx>;
//include <mtlFX.wdl>;
//include <default.fx>;
//include <mtlFX.wdl>;
#include <acknex.h>
#include <default.c>
#include "mtlFX.c"
#define PRAGMA_PATH "%EXE_DIR%\code";
#define PRAGMA_PATH "images";
#define PRAGMA_PATH "terrains";
#define PRAGMA_PATH "levels";
#define PRAGMA_PATH "models";

////////////////////////////////////////////////////////////////////
#define xmax 1024
#define ymax 768
#define fscreen 1
 
BMAP* nneglogo = "nnegamingLOGO.bmp";
BMAP* dhlogo = "dementia_hillsLOGO.bmp";
BMAP* dhmenustart = "dhmenustart.bmp";
BMAP* dhmenustartover = "dhmenustart_over.bmp";
BMAP* mcursor = "brokenarrow.pcx";

ENTITY* skycube;

PANEL* splash1 = {
	pos_x=0;
	pos_y=0;
	layer=2;
	bmap = nneglogo;
	flags = VISIBLE;	
}



PANEL* splash2 = {
	pos_x=0;
	pos_y=0;
	layer=1;
	bmap = dhlogo;
	flags = VISIBLE;	
}

PANEL* mainmenu = {
	pos_x=0;
	pos_y=350;
	layer=3;
	button(0,0,dhmenustart,dhmenustart,dhmenustartover,startworld,NULL,NULL);
	flags = OVERLAY;
}

function startworld(){
	toggle(mainmenu,VISIBLE);
	toggle(splash1,VISIBLE);
	toggle(splash2,VISIBLE);

	//Start Loading Shit
	camera.arc = 30; //Zoom Factor
	while(player == NULL) { wait(1); }
	player.x = 570;
	player.y = -1996;
	player.z = 330;
	player.pan = 323;
   vec_set(camera.x,vector(-180,0,50));
	vec_rotate(camera.x,player.pan);
	vec_add(camera.x,player.x);
	camera.pan = player.pan;
	camera.tilt = -15;
}

action players_code() { 
       var anim_percentage; // animation percentage
       VECTOR movement_speed; // player's movement speed
       var distance_to_ground; // the distance between player's origin and the ground
       VECTOR temp;
       player = my; // I'm the player
		 while (1) {
		 	
		 		//THIS PART CAUSE FLICKERING WHY????!!!
		 	  	vec_set(camera.x,vector(-180,0,50));
				vec_rotate(camera.x,player.pan);
				vec_add(camera.x,player.x);
				camera.pan = player.pan;
				camera.tilt = -15;
				//THAT^ PART CAUSE FLICKERING WHY????!!!
				
		 		my.pan += 6 * (key_a - key_d) * time_step; // rotate the player using the "A" and "D" keys
         	vec_set (temp.x, my.x); // copy player's position to temp
         	temp.z -= 5000; // set temp.z 5000 quants below player's origin
         	distance_to_ground = c_trace (my.x, temp.x, IGNORE_ME | USE_BOX);
         	movement_speed.x = 10 * (key_w - key_s) * time_step; // move the player using "W" and "S"
         	movement_speed.y = 0; // don't move sideways
           	movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
         	movement_speed.z = maxv(-35 * time_step, movement_speed.z); // 35 = falling speed
         	c_move (my, movement_speed.x, nullvector, GLIDE); // move the player
  				if ((key_w == OFF) && (key_s == OFF)) {
					ent_animate(my, "Standa", anim_percentage, ANM_CYCLE); // play the "stand" animation
   	      }	else { 
      	      ent_animate(my, "Walka", anim_percentage, ANM_CYCLE); // play the "walk" animation
         	}
         	anim_percentage += 8 * time_step; // 5 = animation speed
         	wait (1);       
       	}
}




function main()
{
	video_set(xmax,ymax,32,fscreen);
	screen_color.blue=0;
	screen_color.red=0;
	screen_color.green=0;
	wait(2);
	wait(-8);
	splash1.bmap=dhlogo;
	while(splash1.pos_x <= 125) {
		splash1.pos_x += 3 * time_step;
		wait(1);
	}
	toggle(mainmenu,VISIBLE);
	level_load("dh.wmb");
	skycube = ent_createlayer("Sky_2+6.tga", SKY | CUBE | VISIBLE, 0);
	mouse_map= mcursor;
	mouse_mode = 2;
	//delay the inevitable
	while(key_pressed(key_for_str("q"))  == 0) {
		//Process Mouse
		mouse_pos.x = mouse_cursor.x;
      mouse_pos.y = mouse_cursor.y;
      
      //if (player != NULL) {
				//I even tried putting the flicker causing code here
				//still works
				//still flickers
				// :(
		//}
		//next cycle      
		wait(1);
	}
	sys_exit("p00!");
}


Thanks In Advance,
Neurosys


See more code and crap @ www.neuroticnetworks.com
Re: Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! [Re: Neurosys] #220740
08/09/08 01:35
08/09/08 01:35
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
vec_set sets the vector of vector2 to vector1
vec_set(vector1,vector2);

so...
Code:
	vec_set(camera.x,vector(-180,0,50)); //line 1
	vec_rotate(camera.x,player.pan); //2
	vec_add(camera.x,player.x); //3
	camera.pan = player.pan; //4
	camera.tilt = -15; //5

you're setting the camera.x on vec_set line 1st the 2nd line and the 3rd line,

use temp here then here instead of camera.x on those lines, then create a new line between 3 and 4
Code:
vec_set(camera.x,temp);


you may need to tinker with this slightly to get your desired effect! smile

Hope this helps

Re: Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! [Re: MrGuest] #220742
08/09/08 02:14
08/09/08 02:14
Joined: Aug 2008
Posts: 61
Neurosys Offline OP
Junior Member
Neurosys  Offline OP
Junior Member

Joined: Aug 2008
Posts: 61
Originally Posted By: MrGuest

you're setting the camera.x on vec_set line 1st the 2nd line and the 3rd line,

use temp here then here instead of camera.x on those lines, then create a new line between 3 and 4
Code:
vec_set(camera.x,temp);



Ok did that. Heres the new players_code action:


Code:
action players_code() { 
       var anim_percentage; // animation percentage
       VECTOR movement_speed; // player's movement speed
       VECTOR tempcam;
       var distance_to_ground; // the distance between player's origin and the ground
       VECTOR temp;
       player = my; // I'm the player
		 while (1) {
		 	
		 		//THIS PART CAUSEs FLICKERING WHY????!!!
		 	  	vec_set(tempcam.x,vector(-180,0,50));
				vec_rotate(tempcam.x,player.pan);
				vec_add(tempcam.x,player.x);
				vec_set(camera.x,tempcam);
				camera.pan = player.pan;
				camera.tilt = -15;
				//THAT^ PART CAUSEs FLICKERING WHY????!!!
				
		 		my.pan += 6 * (key_a - key_d) * time_step; // rotate the player using the "A" and "D" keys
         	vec_set (temp.x, my.x); // copy player's position to temp
         	temp.z -= 5000; // set temp.z 5000 quants below player's origin
         	distance_to_ground = c_trace (my.x, temp.x, IGNORE_ME | USE_BOX);
         	movement_speed.x = 10 * (key_w - key_s) * time_step; // move the player using "W" and "S"
         	movement_speed.y = 0; // don't move sideways
           	movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
         	movement_speed.z = maxv(-35 * time_step, movement_speed.z); // 35 = falling speed
         	c_move (my, movement_speed.x, nullvector, GLIDE); // move the player
  				if ((key_w == OFF) && (key_s == OFF)) {
					ent_animate(my, "Standa", anim_percentage, ANM_CYCLE); // play the "stand" animation
   	      }	else { 
      	      ent_animate(my, "Walka", anim_percentage, ANM_CYCLE); // play the "walk" animation
         	}
         	anim_percentage += 8 * time_step; // 5 = animation speed
         	wait (1);       
       	}
}


As you can see I have done it and it still flickers frown
Thats what I meant by "wtf is moving the camera now?"
lol wierd huh! o and the F11 still shows it jumping between
the right place and some obscene vector(the flickerframe position).


See more code and crap @ www.neuroticnetworks.com
Re: Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! [Re: Neurosys] #220747
08/09/08 02:42
08/09/08 02:42
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
i'm not sure if it'll solve the problem but you should have the camera updating its position after the player has moved, it may/should make it a little smoother

other than that i can't see what's wrong unless you've given that player_code to 2 entities... or someone in your computer really doesn't like you smirk

Re: Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! [Re: MrGuest] #220753
08/09/08 03:19
08/09/08 03:19
Joined: Aug 2008
Posts: 61
Neurosys Offline OP
Junior Member
Neurosys  Offline OP
Junior Member

Joined: Aug 2008
Posts: 61
did that too ... still flickers... driving me nuts... my game is so ready to start having some development fun and this tiny thing is killin me


See more code and crap @ www.neuroticnetworks.com
Re: Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! [Re: Neurosys] #220754
08/09/08 03:54
08/09/08 03:54
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
this ones got me stumped and it's probably something really simple, 1 last shot before bed

if you change the angle of the camera before settings it's position is it any better?

else put
Code:
proc_late(); 
above everything in that action smirk

other than that i wish you luck! smile

Re: Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! [Re: MrGuest] #220757
08/09/08 04:38
08/09/08 04:38
Joined: Aug 2008
Posts: 61
Neurosys Offline OP
Junior Member
Neurosys  Offline OP
Junior Member

Joined: Aug 2008
Posts: 61
proc_mode=PROC_LATE for litec... tried it... no go... also tried many combos of the vec stuff.. same thing everytime... i know i agree its prolly super simple.

o btw.. I loaded up the AUM workshop 36 (issue 61) code these lines are from... it does the same thing... here look... http://aum.conitec.net/aum61code.zip

mind buggling... I keep wanting to use the old method of cosin and sin'in the players pan but i cant member how frown .. saw it in aum earlier today even lol.


See more code and crap @ www.neuroticnetworks.com
Re: Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! [Re: Neurosys] #220760
08/09/08 05:18
08/09/08 05:18
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
i didnt check your code yet but here is the cos sin one:

int camera_distance = 40;

camera.x = player.x - camera_distance * cos(camera.pan);
camera.y = player.y - camera_distance * sin(camera.pan);
camera.z = player.z + camera_distance*0.8;

but i still prefer the vectory one. be ware if your fps is higher your camera turns faster with the code above.


edit: it didnt flickered for me.

Last edited by Quadraxas; 08/09/08 05:21.

3333333333
Re: Third Person Camera Movement WORKS GREAT but SCREEN FLICKERS! [Re: Quad] #220761
08/09/08 05:55
08/09/08 05:55
Joined: Aug 2008
Posts: 61
Neurosys Offline OP
Junior Member
Neurosys  Offline OP
Junior Member

Joined: Aug 2008
Posts: 61
yea i was just coming back to go yay i got it.. thanks quadraxas and MrGuest..

i finally used this...

Code:
action players_code() { 
		 var anim_percentage; // animation percentage
       VECTOR movement_speed; // player's movement speed
       VECTOR tempcamera;
       var distance_to_ground; // the distance between player's origin and the ground
       var camdist = 230;
       var camheight = 70;
       VECTOR temp;
       VECTOR* temp2;
       player = my; // I'm the player
		 while (1) {
				camera.x=player.x - camdist * cos(player.pan);
				camera.y=player.y - camdist * sin(player.pan);
				camera.z = player.z + camheight;
				camera.pan=player.pan;
				camera.tilt = -10;
				
		 		//THIS PART CAUSEs FLICKERING WHY????!!!
				//vec_set(camera.x,vector(-180,0,50));
				//vec_rotate(camera.x,player.pan);
				//vec_add(camera.x,player.x);
				//camera.pan = player.pan;
				//camera.tilt = -15;
				//THAT^ PART CAUSEs FLICKERING WHY????!!!
				my.pan += 6 * (key_a - key_d) * time_step; // rotate the player using the "A" and "D" keys
         	vec_set (temp.x, my.x); // copy player's position to temp
         	temp.z -= 5000; // set temp.z 5000 quants below player's origin
         	distance_to_ground = c_trace (my.x, temp.x, IGNORE_ME | USE_BOX);
         	movement_speed.x = 10 * (key_w - key_s) * time_step; // move the player using "W" and "S"
         	movement_speed.y = 0; // don't move sideways
           	movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
         	movement_speed.z = maxv(-35 * time_step, movement_speed.z); // 35 = falling speed
         	c_move (my, movement_speed.x, nullvector, GLIDE); // move the player
  				if ((key_w == OFF) && (key_s == OFF)) {
					ent_animate(my, "Standa", anim_percentage, ANM_CYCLE); // play the "stand" animation
   	      }	else { 
      	      ent_animate(my, "Walka", anim_percentage, ANM_CYCLE); // play the "walk" animation
         	}
         	anim_percentage += 8 * time_step; // 5 = animation speed
         	wait (1);       
       	}
}


works beautifully.


See more code and crap @ www.neuroticnetworks.com

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1