Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,501 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
How Do I Move An Entity??? #163474
10/26/07 00:43
10/26/07 00:43
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27
In my last post I was concerned about selecting an entity in the 3d environment ... well, I solved it ... as I said I am in the process of creating an RTS game ... after I have the entity selected ... how do I move it around the terrain ... Ive tried c_move ... in many different ways ... why can't I get my objects to move??

Re: How Do I Move An Entity??? [Re: phmenard] #163475
10/26/07 11:36
10/26/07 11:36
Joined: Apr 2006
Posts: 624
DEEP 13
badapple Offline
User
badapple  Offline
User

Joined: Apr 2006
Posts: 624
DEEP 13
maybe you should post your movement code so people can see what wrong
you might get a better response

Re: How Do I Move An Entity??? [Re: badapple] #163476
10/26/07 11:53
10/26/07 11:53
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27

Here is some of the code I am using ... selected is a pointer to the selected entity, temp and temp2 are globals ... I know they should be more descriptive but this is just test code, once I get it to work I make the code all pretty ... :-). The object selected does move, but very wildly ... this is not what I want.


function moveObject()
{
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 100;

temp2.x = selected.x; temp2.y = selected.y; temp2.z = selected.z;

while(temp.x != selected.x && temp.y != selected.y && temp.z != selected.z)
{
c_move (selected, temp2, temp, GLIDE);
wait(1);
}

}

Re: How Do I Move An Entity??? [Re: phmenard] #163477
10/26/07 15:01
10/26/07 15:01
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline
Member
dennis  Offline
Member

Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
You have to convert the mouse position to the 3D world position first...then you should turn the model so that it points to the position and move it relatively.

Could be like this.

Code:
while(1)
{

mouse_mode = 4;
mouse_range = 10000;
mouse_map = IM_MOUSE;

mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;

Temp1[0] = mouse_pos.x;
Temp1[1] = mouse_pos.y;
Temp1[2] = 50;
vec_for_screen(Temp1,camera);

Temp2[0] = mouse_pos.x;
Temp2[1] = mouse_pos.y;
Temp2[2] = 5000;
vec_for_screen(Temp2,camera);

c_trace(Temp1,Temp2,IGNORE_PASSABLE | IGNORE_YOU);
target.z += 30;
vec_set(my.Target_X,target.x);

if(vec_dist(my.x,my.Target_X) > 14)
{
my.skill1 = 5*time_step;
}

vec_diff(Temp,my.Target_X,my.x);
Temp[2] = 0;
vec_to_angle(my.pan,Temp);

}



Temp1 und Temp2 sind globale Vektoren.

Re: How Do I Move An Entity??? [Re: dennis] #163478
10/26/07 15:59
10/26/07 15:59
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27
Didn't work at all ... first of all I keep getting errors saying that Target_X is not a member of ENTITY. I changed all the my's to the entity that is selected and got something similar to what I get with my code. HMMM with everything else in this language being relatively simple it bugs me that I can't get something as simple as a truck driving along my terrain to work.

Re: How Do I Move An Entity??? [Re: phmenard] #163479
10/26/07 16:09
10/26/07 16:09
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline
Member
dennis  Offline
Member

Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...

Add that before the entity action...

"
#define Target_X skill56
#define Target_Y skill57
#define Target_Z skill58
"

and add this after vec_to_angle

"
c_move(me,my.skill1,nullvector,GLIDE + IGNORE_ME);
"

Re: How Do I Move An Entity??? [Re: dennis] #163480
10/26/07 16:52
10/26/07 16:52
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27
I did what you said and now the whole program crashes ... ugggg this is the complete code ... "selected" is the entity that has been selected with a left mouse click ... a right click then calls the following ...

function moveObject()
{
while(1){
mouse_mode = 4;
mouse_range = 10000;
//mouse_map = IM_MOUSE;
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;

Temp1.x = mouse_pos.x;
Temp1.y = mouse_pos.y;
Temp1.z = 50;

vec_for_screen(Temp1,camera);

Temp2.x = mouse_pos.x;
Temp2.y = mouse_pos.y;
Temp2.z = 5000;

vec_for_screen(Temp2,camera);

c_trace(Temp1,Temp2,IGNORE_PASSABLE | IGNORE_YOU);
target.z += 30;
vec_set(selected.x,target.x);
if(vec_dist(my.x,my.Target_X) > 14)
{
selected.skill1 = 5*time_step;
}

vec_diff(Temp,selected.x,selected.x);
Temp.y = 0;
vec_to_angle(selected.pan,Temp);
c_move(selected,selected.skill1,nullvector,GLIDE + IGNORE_ME);
wait(1);
}

}

I changed the Temp variables to normal vectors, I couldn't understand why they were arrays ... Temp1[] and Temp2[] maybe I shoudn't have done that but it didn't even compile that way.

Re: How Do I Move An Entity??? [Re: phmenard] #163481
10/26/07 16:54
10/26/07 16:54
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27
in the if(vec .... ) I change them my to selected as well, but the above code doesn't show that.

Re: How Do I Move An Entity??? [Re: phmenard] #163482
10/26/07 17:16
10/26/07 17:16
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27
Ok, I'm getting close ... I moved the while() loop down the code a bit ... now the objects are moving a little better ... but go off in random directions rather than making there way to were I right click ... new code ..... any suggestions ....

function moveObject()
{

mouse_mode = 4;
mouse_range = 10000;
//mouse_map = IM_MOUSE;
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;

Temp1.x = selected.x;
Temp1.y = selected.y;
Temp1.z = 50;

vec_for_screen(Temp1,camera);

Temp2.x = mouse_pos.x;
Temp2.y = mouse_pos.y;
Temp2.z = 5000;

vec_for_screen(Temp2,camera);

c_trace(Temp1,Temp2,IGNORE_PASSABLE | IGNORE_YOU);
target.z += 30;
vec_set(selected.Target_X,target.x);
while(1){
if(vec_dist(selected.x,selected.Target_X) > 14)
{
selected.skill1 = 5*time_step;
}

vec_diff(Temp,selected.Target_X,selected.x);
Temp.y = 0;
vec_to_angle(selected.pan,Temp);

c_move(selected,selected.skill1,nullvector,GLIDE + IGNORE_ME);
wait(1);
}

}

Re: How Do I Move An Entity??? [Re: phmenard] #163483
10/26/07 17:43
10/26/07 17:43
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline
Member
dennis  Offline
Member

Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...

You want to move the entity like in a strategy game, don't you?

Page 1 of 2 1 2

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