|
again a basic question about move
#337379
08/10/10 17:31
08/10/10 17:31
|
Joined: Jul 2010
Posts: 127 Germany, Herford
Ditje
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 127
Germany, Herford
|
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
Last edited by Ditje; 08/10/10 17:32.
|
|
|
Re: again a basic question about move
[Re: Ditje]
#337382
08/10/10 17:37
08/10/10 17:37
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
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); }
|
|
|
Re: again a basic question about move
[Re: Rei_Ayanami]
#337420
08/10/10 19:39
08/10/10 19:39
|
Joined: Jul 2010
Posts: 127 Germany, Herford
Ditje
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 127
Germany, Herford
|
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
|
|
|
Re: again a basic question about move
[Re: Ditje]
#337477
08/11/10 06:08
08/11/10 06:08
|
Joined: Jul 2010
Posts: 127 Germany, Herford
Ditje
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 127
Germany, Herford
|
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.wmvIn 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 THANKS Ditje Edit: Maybe this pic helps to understand, what I want
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;
}
Last edited by Ditje; 08/11/10 11:16.
|
|
|
Re: again a basic question about move
[Re: Ditje]
#337535
08/11/10 15:01
08/11/10 15:01
|
Joined: Mar 2002
Posts: 1,774 Magdeburg
FlorianP
Serious User
|
Serious User
Joined: Mar 2002
Posts: 1,774
Magdeburg
|
Try this
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;
}
I <3 LINQ
|
|
|
Re: again a basic question about move
[Re: FlorianP]
#337657
08/12/10 11:21
08/12/10 11:21
|
Joined: Jul 2010
Posts: 127 Germany, Herford
Ditje
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 127
Germany, Herford
|
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 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 Hilfe ich bin echt am verzweifeln Ditje
Last edited by Ditje; 08/12/10 11:22.
|
|
|
Re: again a basic question about move
[Re: Ditje]
#337756
08/13/10 06:12
08/13/10 06:12
|
Joined: Jul 2010
Posts: 127 Germany, Herford
Ditje
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 127
Germany, Herford
|
I switched back to my first version. But I think this is not "clean" What I did:
// 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
|
|
|
|