stuck player

Posted By: JazzDude

stuck player - 03/15/10 05:10

There's something wrong with this section of my player code. The player gets stuck in the stand animation and won't respond to the mouse_right until he hits a certain pan position--not always the same one.

I've tried every collision trick in the manual and a few from AUM and the forum but can't solve the problem.

Code:
player = my; 
c_setminmax(me);
vec_set(my.min_x,vector(-15,-15,-50));
vec_set(my.max_x,vector(15,15,50));
my.z = 60;
   while (1)
      {
   	 player.pan -= 5 * mouse_force.x * time_step; 
         if(key_pressed(281)) //mouse right
          {
           ent_animate(my, "walk", walk_percentage, ANM_CYCLE); 
           walk_percentage += 7 * time_step; 
           walk_percentage %= 100;
           
	if (walk_percentage < 10)
   	{
	      sounded_once = 1;
	}
	if ((walk_percentage > 50) && (sounded_once == 1)) 
	{
	    sounded_once = 2;              
	    ent_playsound(my, step2_wav, 70);              
			}               
	if ((walk_percentage > 95) && (sounded_once == 2)) 
	{
	    sounded_once = 3;              
	    ent_playsound(my, step2_wav, 70);              
	}
	c_move (my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE );
	temp.x = movement_speed * (mouse_right)*0.6 * time_step;
         }
      else
         {
         ent_animate(my, "stand", stand_percentage, ANM_CYCLE); 
         stand_percentage += 5 * time_step; 
	}
	wait(1);
	}



That isn't all the action, of course, but the rest of it --camera, gravity--seems to be working okay.
Posted By: Blink

Re: stuck player - 03/15/10 10:40

Hey Rod, is the wait(1); in the right place? shouldnt it look like this?

ent_animate(my, "stand", stand_percentage, ANM_CYCLE);
stand_percentage += 5 * time_step;
wait(1);

then the bracket? i am no pro, just wondering. and arent you missing the skill number?
Posted By: JazzDude

Re: stuck player - 03/15/10 19:53

I've isolated it to the player.pan line. Without it everything else works.
Posted By: flits

Re: stuck player - 03/16/10 07:57

you could beter use c_rotate instead of using player.pan

this way it can get stuck in lvl geomtry
Posted By: JazzDude

Re: stuck player - 03/16/10 15:44

Yes, I used that too. I think the problem is with the camera when the player turns. I'm reworking that this morning.
Posted By: Blink

Re: stuck player - 03/17/10 17:49

Rod, did you every figure this out?
Posted By: JazzDude

Re: stuck player - 03/18/10 00:27

Yeah, but don't ask me how. I played with it for three days. Rewrote it from scratch a few times. Borrowed ideas from AUM. And made several hundred minor and major changes. Somewhere in that mess it was cured. So I still don't know the cause or the cure. crazy
Posted By: Blink

Re: stuck player - 03/18/10 01:03

well, i guess its better to be lucky then. i can't wait to see what you have up your sleeve for your next great adventure. i admire your dedication, and great works. you inspire me, Rod!
Posted By: JazzDude

Re: stuck player - 03/18/10 19:25

Ah crap....I tried the game on my weaker PC and the problem returned. I think I'll take up knitting. sick
Posted By: Blink

Re: stuck player - 03/18/10 23:14

no, dont give up Rod.
Posted By: Superku

Re: stuck player - 03/18/10 23:48

Try to load an empty level and test the script, it works fine for me:

Quote:

///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

function player_action() {
VECTOR temp;
var walk_percentage = 0, stand_percentage = 0, movement_speed = 10;
player = my;
c_setminmax(me);
vec_set(my.min_x,vector(-15,-15,-50));
vec_set(my.max_x,vector(15,15,50));
while (1)
{
player.pan -= 5 * mouse_force.x * time_step;
if(key_pressed(281)) //mouse right
{
ent_animate(my, "walk", walk_percentage, ANM_CYCLE);
walk_percentage += 7 * time_step;
walk_percentage %= 100;

temp.x = movement_speed * (mouse_right)*0.6 * time_step;
temp.y = 0;
temp.z= 0;
c_move (my, temp, nullvector, IGNORE_PASSABLE | GLIDE );
}
else
{
ent_animate(my, "stand", stand_percentage, ANM_CYCLE);
stand_percentage += 5 * time_step;
}
wait(1);
}
}


function main() {
fps_max = 60;
video_mode = 11;

level_load(NULL);
wait(1);

ent_create("player.mdl",vector(330,0,0),player_action);
}

Posted By: KlongKiller

Re: stuck player - 03/20/10 23:18

I have also tried using c_move and c_rotate and for me they get stuck often. I played around with them for a couple weeks and decided to make my own using ray tracing, I was suprised to find very satisfying results with my own version... I think the reason is that I completely understand how mine works because I coded it, I am also using a it on a level with a lot of crazy geometry(A model with the polygon flag set) and it still works smoothly instead of a level made in wed(mostly 90degree angled blocks) I recently finished the gravity code and have moved forward with my project. If you are interested on how I did It I suppose I could make time
Posted By: JazzDude

Re: stuck player - 03/21/10 14:58

I solved the problem. I was reworking an old game made with A5 and some of the furniture in the room was prefabs. I replaced all of those prefabs with models with polygon set on. Now all's well. Since there was no problem with A5 I can only presume that levels made in A5 WED and A6 WED aren't compatible for collision purposes. Sounds like a dumb guess, LOL.

Now...if someone could give me a workaround to keep the mouse trapped in a window I would be done with this beast.
Posted By: Superku

Re: stuck player - 03/21/10 18:26

I think it's only possible in lite-c (but not 100% sure). There you have access to Windows-functions:

Originally Posted By: DJBMASTER
#include <acknex.h>
#include <windows.h>

void main()
{
mouse_pointer = 0;
RECT* rect;
GetWindowRect(hWnd,rect);
ClipCursor(rect);
}

Posted By: JazzDude

Re: stuck player - 03/22/10 16:51

I wanted to include a window mode for widescreen monitors to preserve the aspect ratio. However, in the shooting action the mouse would get outside of the window and minimize the game window. My workaround is to use this snippet by Mercuryus which keeps the aspect ration of the game at 4/3.

I just got a widescreen monitor a couple days ago and the code works very well.
Posted By: gotobrain

Re: stuck player - 03/30/10 00:43

Post deleted.
© 2024 lite-C Forums