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,430 guests, and 3 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
How Do I Move An Entity Around The Terrain #163754
10/27/07 15:56
10/27/07 15:56
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27
I'm in the process of writing an RTS game (Real Time Strategy) I have no problems placing objects in my worlds. The problem come up when I try to select and move objects suck as tanks and other vehicles around the terrain, the entities float around the map ... sometimes take off into space wildly ... lol what am I doing wrong ... here is some of the code I am using ....

Code:
 function selectObject()
{

if(!mouse_ent) { Selected = NULL; return; }
//if(mouse_ent.ID != ID_Human) return;

Selected = mouse_ent;

}



Code:
 #define Target_X skill2
#define Target_Y skill3
#define Target_Z skill4
#define Move_Speed_X skill5
#define Move_Speed_Y skill6
#define Move_Speed_Z skill7

function moveObject()
{
var Temp1[3];
var Temp2[3];

if(!Selected) return;

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 += 40;

vec_set(Selected.Target_X,target.x);
while(1)
{

// Target?

if(Selected.Target_X != 0 && Selected.Target_Y != 0 && Selected.Target_Y != 0)
{

// Turn towards the Target

vec_diff(Temp1,Selected.Target_X,Selected.x);
vec_to_angle(Selected.pan,Temp1);


// Move towards Target

if(vec_dist(Selected.x,Selected.Target_X) > 50)
{

Selected.Move_Speed_X = 4*time_step;
c_move(Selected,Selected.Move_Speed_X,nullvector,IGNORE_ME | IGNORE_PASSABLE | GLIDE);

} else {

vec_set(Selected.Target_X,nullvector);

}

}

// Set on ground

c_trace(Selected.x,vector(Selected.x,Selected.y,Selected.z-1000),IGNORE_ME | IGNORE_PASSABLE);
Selected.z -= result-40;

wait(1);

}

}



Selected is a global vector that holds the entity selected. Any help will be greatly appreciated.

Re: How Do I Move An Entity Around The Terrain [Re: phmenard] #163755
10/27/07 18:44
10/27/07 18:44
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
This isn't physics; Belongs in Scripting.

Re: How Do I Move An Entity Around The Terrain [Re: fastlane69] #163756
10/27/07 18:55
10/27/07 18:55
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27
I tried that ... but someone from there told me the reason my entities are acting so weird is because I am using the physics engine. They told me to come here and see if someone could help.

Re: How Do I Move An Entity Around The Terrain [Re: phmenard] #163757
10/27/07 19:35
10/27/07 19:35
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
LOL that someone was wrong! You are only using c_move which is not the physics engine. Physics engine commands use Phent_, not c_.

Re: How Do I Move An Entity Around The Terrain [Re: fastlane69] #163758
10/27/07 20:25
10/27/07 20:25
Joined: Oct 2007
Posts: 27
P
phmenard Offline OP
Newbie
phmenard  Offline OP
Newbie
P

Joined: Oct 2007
Posts: 27
ok, thats fine ... is there an example out there I can look at. An yes he did say I can't use c_move, I pasted the code to show what I was trying to do ... all I want is some help, maybe an example. thats all.

Re: How Do I Move An Entity Around The Terrain [Re: phmenard] #163759
10/28/07 07:17
10/28/07 07:17
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Whoever you are listening to... stop!

c_move is the proper choice for an RTS. Unless you have a very specific reason for wanting your units to be physical (it would be very neat btw but not at all the way RTSs are right now), c_move is the right command for the job.

Re: How Do I Move An Entity Around The Terrain [Re: fastlane69] #163760
10/28/07 14:44
10/28/07 14:44
Joined: Jul 2006
Posts: 150
Deutschland/Germany, nahe Hamb...
dennis Offline
Member
dennis  Offline
Member

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

Hi fastlane69,

I was the one who told him...

I said that he cannot use c_move with physics and that I don't know how to move an entity properly which is physical. So I told him to ask in this (Physics) forum how to move an physics entity.....

I also said that I would prefer c_move but if he wants his units to be physically he can also do that with 3DGS.

Can you post an example (e.g. a tank movement) code ? (physics)

Re: How Do I Move An Entity Around The Terrain [Re: dennis] #163761
10/28/07 17:53
10/28/07 17:53
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Gotcha. That makes more sense. From his posts, I got the impression that people were telling him that c_move was physics.

As it stands, his original post belongs in scripting since there is no physics here.

(PS: Nobody that I know has ever done RTS physically and that is not my area of expertise. You would have to post that in "user requests" to get an answer)


Moderated by  HeelX, Spirit 

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