Terrains and Movement

Posted By: Carlos3DGS

Terrains and Movement - 07/23/11 21:57

I have a terrain and am using c_move to move my character but it goes right through the terrain. My question is... Am I doing it wrong or does c_move not interact with terrains?

Can anyone point me in the right direction?

Another question: after creating a terrain... Is there any way to modify its position? I tried to direclty change it's x and y coordinate values but it dosnt seem to work. On creation I can place it where I want but afterwards I cant seem to "re-locate" it. Is this some kind of restraint of how terrains work?
Posted By: xxxxxxx

Re: Terrains and Movement - 07/23/11 22:11

1: Please post ur code, so we can say u what u are doing wrong(c_move interact with terrains).
2: Did you tried the DYNAMIC flag????
xxxxxxx
Posted By: 3run

Re: Terrains and Movement - 07/24/11 06:47

"c_move" interact with everything, to interact with terrains you simply need to do this:
Code:
dist.x = 10 * (key_w - key_s) * time_step;
dist.y = 10 * (key_a - key_d) * time_step;
dist.z = 10 * (key_q - key_e) * time_step;
c_move(my,dist,nullvector,IGNORE_PASSABLE|GLIDE);

So you can move player with WSAD in X and Y coordinates, plus with QE in Z.
Take a look at your "c_move", may be you are using "IGNORE_WORLD" in it.
Or may be "IGNORE_FLAG2" and you terrain has FLAG2 set on... I can't see any other reasons.
Posted By: Carlos3DGS

Re: Terrains and Movement - 07/24/11 12:22

I know how to use c_move, but thankyou for taking the time to reply in case I didnt.

Just in case I post my movement code, mabe I am missing some mistake and someone else can help find it:

Code:
c_move(Boat,vector((key_cuu-key_cud)*20*time_step,0,0),nullvector,IGNORE_PASSABLE);
c_rotate(Boat,vector((key_cul-key_cur)*2*time_step,0,0),IGNORE_PASSABLE);


My terrain does not have the passable set so that should not be the problem. Just to make sure i removed the IGNORE_PASSABLE mode from the movement and I still have that problem... I just go right through the terrains
Posted By: Carlos3DGS

Re: Terrains and Movement - 07/24/11 12:38

I found the problem.
I modify my terrains at runtime with functions like these:
Code:
ENTITY* CurrSand;
	int VecTotal = ent_status(Sand[2][2],0);//terrain total vectors
	var VecDist;//store distance to terrain center
	
	int tx; int ty; int i;
	
	
	for (i=VecTotal; i>0; i--)
	{
		for(tx=0;tx<5;tx++)
		{
			for(ty=0;ty<5;ty++)
			{
				CurrSand=Sand[tx][ty];
				CONTACT* c1 = ent_getvertex(CurrSand,NULL,i);
				
				if(CurrSand.skill1==1)
				{
					VecDist=vec_dist(vector(((i-1)%33),(integer((i-1)/33)),0),vector(16,16,0));
					
					if(VecDist<=10)
					{
						c1.v.y= (-1*((2*(VecDist))*(2*(VecDist))))+50;
					}
					else
					{
						c1.v.y= -360;
					}
				}
				else
				{
					c1.v.y = -360;
				}
				ent_setvertex(CurrSand,c1,i);
			}
		}
	}


I added a few lines of code after I modify the terrains to update the hull and it fixed the problem:
Code:
for(tx=0;tx<5;tx++)
	{
		for(ty=0;ty<5;ty++)
		{
			c_updatehull(Sand[tx][ty],1);
		}
	}


Posted By: Carlos3DGS

Re: Terrains and Movement - 07/24/11 17:31

Another question regarding movement and collision.
I want my player to glide around objects but never glide upwards (over hills). Is there any way to limit the glide along the z axis?

EDIT:
nevermind... I found it "disable_z_glide = 1;"

New Question;
My terrains have no feeling of depth, mainly because they have no shadow. I tried setting the SHADOW flag but it dosnt do anything. I think this is probably because I modify my terrains during runtime... Is there any way to get them to cast shadows on themselves again like pre-made terrains have?
Posted By: Joey

Re: Terrains and Movement - 07/24/11 20:48

ent_fixnormals is one step. dropping shadows would need a shader, I don't think stencil shadows on terrain look good. static lighting is not available for modified meshes.
Posted By: Carlos3DGS

Re: Terrains and Movement - 07/24/11 21:46

ent_fixnormals fixed the problem. Thankyou very much!
© 2024 lite-C Forums