Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 16,005 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
tank movement #238184
11/25/08 13:07
11/25/08 13:07
Joined: Nov 2007
Posts: 60
D
darci Offline OP
Junior Member
darci  Offline OP
Junior Member
D

Joined: Nov 2007
Posts: 60
hi ^^

i want to make a tank moving but these are my problems

1. i dont know how i can make the chain move, could it be possible do do it with a moving texture or are there other ways for it

2. i dont know it how the tank can be controled right, with a mouseclick on the ground the tank should move to that position

3. its quite important that that all look real, i mean the tank should make distinction between hils and holes

^^ it would be wunderfull if you can help me with some ideas,

everything is better than nothing

Re: tank movement [Re: darci] #238199
11/25/08 15:23
11/25/08 15:23
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
1. The treads can move in 1 of two different ways. The simpler way would be to make them as a separate model and just move the texture via UV coordinates. The harder way would be to actually animate them.

2. To move an object from its location to the point of a mouse click, what I would do is have a trace fired from the mouse to the ground. Then take target, which is modified by c_trace, vec_set it into a vector for your tank to go to and then pathfind to that location.

This untested code has no pathfinding, but should move a tank to a position where the mouse clicks
Code:
VECTOR targVec;
int iMouseTraced = 0;

int mouseTrace()
{
	VECTOR from;
   VECTOR to;
   from = vec_for_vertex(mouse_pos,camera);
   to.x = mouse_pos.x;
   to.y = mouse_pos.y;
   to.z = -3000;   //somewhere underground
   c_trace(from,to,IGNORE_PASSABLE |  IGNORE_SPRITES | IGNORE_MODELS);
   vec_set(targVec,target);
   return(1);
}

action moveTank()
{
  VECTOR speed;
  my.health = 100;
  while(my.health > 0)
  {
    if(mouse_left)
    {
    	iMouseTraced = mouse_trace();
    }
    if(iMouseTraced)
    {
    	vec_sub(targVec,my.x);
    	vec_to_angle(my.pan,targVec);
    	speed.x = 10 * time_step;
    	if(vec_dist(my.x,targVec) >= 150)
    	{
    		c_move(my,speed,nullvector,IGNORE_PASSABLE | GLIDE);
    	}
    }
    wait(1);
  }
     
}


What it does, is in the action, it waits for the LMB to be pressed. When that occurs, mouseTrace is called. In mouse trace, the from vector takes the mouse position and converts it into 3d coordinates. The to vector takes the same coordinates but goes underground. Then I trace from those two vectors and the target will be on the ground somewhere.

Since target is only valid for one frame, I copy its value into the vector targVec. Then I have the function return a 1 so that the tank knows that he has a target destination and moves.

Back in the moveTank() action, if iMouseTraced is 1, then the next two lines make the tank face the target vector, then he moves via c_move so long as he's greater than 150 units from the target (I've done something similar before, you won't get on the vector exactly)

3. Since I'm trying to work on this myself, I do not yet have an answer.


I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: tank movement [Re: heinekenbottle] #238206
11/25/08 16:28
11/25/08 16:28
Joined: Nov 2007
Posts: 60
D
darci Offline OP
Junior Member
darci  Offline OP
Junior Member
D

Joined: Nov 2007
Posts: 60
well i think ive nunderstood that code, ^^ big thanks

i hove i can get it in my script


one more questions, how do you create your scripts, all function in one script or have more scripts for one program?


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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