again a basic question about move

Posted By: Ditje

again a basic question about move - 08/10/10 17:31

I tried alredy different variants with c_move but got no solution. My problem:

I have an entity anywhere in my level on position me.x me.y me.z
Now it should move to a fixed position for example x=0 y=800 z=200.

How can I get this?

Thanks and Cheers

Ditje
Posted By: Rei_Ayanami

Re: again a basic question about move - 08/10/10 17:37

do you want collision avoidance ?

Or do you just want to go there?

vec_set(temp, vector(0,800,200));
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
while(vec_dist(my.x, vector(0,800,200)) > 2)
{
c_move(me, vector(10*time_step,0,0),nullvector,GLIDE);
wait(1);
}
Posted By: Ditje

Re: again a basic question about move - 08/10/10 19:39

enemy should go there and wait for attack. Collision is prepared by groups, but not done yet.

I couldn`t work with your script now. I recognized 2 problems:
- me is already already in a while loop
- me moves by y-axxis

The pitty is, that vec-functions are very rarely descibed in the manual. I am still testing - it helps me to understand laugh
Posted By: Ditje

Re: again a basic question about move - 08/11/10 06:08

OK - I`ve got the while and y-problem, but now there is another. ENTITY still doesn`t find the right position. Please take a look to the vid (just 746 kb)

http://www.open-beats.de/temp/galaga_move_problem.wmv

In STATE 7 I put ENTITY without moving on their target position. You can see that ENTITY is far away from target postion at the end of moving to target in STATE 4.

BTW there is no STATE 5 and STATE 6. It`s free for additional moving laugh

THANKS Ditje

Edit: Maybe this pic helps to understand, what I want laugh



Code:
if(my.STATE == 4)
			{
				var temp;
				vec_set(temp, vector(epos[my.ENEMID][0], epos[my.ENEMID][1], epos[my.ENEMID][2]));
				vec_sub(temp, my.x);
				vec_to_angle(my.pan, temp);
				if(vec_dist(my.y, vector(epos[my.ENEMID][0],epos[my.ENEMID][1],epos[my.ENEMID][2])) > 2)
				{
					if(me.y < 800)c_move(me, vector(0,0,0),vector(0,enemy_speed*time_step,0), IGNORE_ME | IGNORE_PUSH);
					else my.STATE = 7;
				}
			}
			if(my.STATE == 7)
			{
				// Drehungen zurückstellen - Endposition
				me.pan = 0;
				me.tilt = 0;
				me.roll = 0;
				me.x = epos[my.ENEMID][0];
				me.y = epos[my.ENEMID][1];
				me.z = epos[my.ENEMID][2];
				// zusätzliche Gegner entfernen
				if(my.ENEMID > 40) ent_remove(me);
				return;
				my.STATE = 8;
			}


Posted By: FlorianP

Re: again a basic question about move - 08/11/10 15:01

Try this

Code:
if(my.STATE == 4)
			{
				var temp;
				vec_set(temp, vector(epos[my.ENEMID][0], epos[my.ENEMID][1], epos[my.ENEMID][2]));
				vec_sub(temp, my.x);
				vec_to_angle(my.pan, temp);
				if(vec_dist(my.x, vector(epos[my.ENEMID][0],epos[my.ENEMID][1],epos[my.ENEMID][2])) > enemy_speed*time_step)
				{
					c_move(me, vector(enemy_speed*time_step,0,0),nullvector, IGNORE_ME | IGNORE_PUSH);					
				}else my.STATE = 7;
			}
			if(my.STATE == 7)
			{
				// Drehungen zurückstellen - Endposition
				me.pan = 0;
				me.tilt = 0;
				me.roll = 0;
				me.x = epos[my.ENEMID][0];
				me.y = epos[my.ENEMID][1];
				me.z = epos[my.ENEMID][2];
				// zusätzliche Gegner entfernen
				if(my.ENEMID > 40) ent_remove(me);
				return;
				my.STATE = 8;
			}


Posted By: Ditje

Re: again a basic question about move - 08/12/10 11:21

Thanks, but sorry. It doesn`t work for me. I tried all variants (x,y,z) of vec_sub and vec_dist. ENTITY doesn`t change angle when it reaches STATE 7.

reldist moving has to be by z axxis, else ENTITY moves anywhere laugh But I would like to use absdist by y axxis, because I want to rotate ENTITY while it moves.

Last thing - if(vec_dist) statement doesn`t work. ENTITY should move to y=800, but moves futher.

I am a little bit confused that ent_move has been replaced by c_move in lite-C. c_move doesn`t do the same. I suppose ent_move would have been easier.

Moving an entity from any position to a fixed one should be a real basic function like:

c_move_distance(ENTITY,vector(destination),vector(target), collision mode);

But it`s as difficult. I am despairing laugh

Hilfe ich bin echt am verzweifeln laugh

Ditje
Posted By: Ditje

Re: again a basic question about move - 08/13/10 06:12

I switched back to my first version. But I think this is not "clean" laugh

What I did:

Code:
// calculate x,y,z distance from me to target
// divide to dercrease speed (value "calculated" by try and error :)
c_wert_x = (epos[my.ENEMID][0] - my.x)/(0.1*enemy_speed);
c_wert_y = (epos[my.ENEMID][1] - my.y)/(0.1*enemy_speed);
c_wert_z = (epos[my.ENEMID][2] - my.z)/(0.1*enemy_speed);


// move ENTITY on absdist
c_move(me, vector(0, 0, 0), vector(c_wert_x*time_step, c_wert_y*time_step, c_wert_z*time_step), IGNORE_ME | IGNORE_PUSH);



I seems to me, that ENTITY is getting slower, when it moves near to target. But it works and can be easily replaced, when I have learned how to do it better laugh
© 2024 lite-C Forums