Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, howardR), 472 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 3 of 4 1 2 3 4
Re: [Sub] Pathfinding [Re: Wade_Adams] #36283
03/22/05 04:40
03/22/05 04:40
Joined: Feb 2005
Posts: 28
abetrader Offline
Newbie
abetrader  Offline
Newbie

Joined: Feb 2005
Posts: 28
Your tutorial is great.
I am trying to implement it into my game which is a hovercraft game.
If I place a node high up in a room how do I program the enemy craft to rotate upward and go up.

Thanks

Re: [Sub] Pathfinding [Re: abetrader] #36284
03/23/05 11:03
03/23/05 11:03
Joined: Nov 2003
Posts: 1,257
Wade_Adams Offline OP
Serious User
Wade_Adams  Offline OP
Serious User

Joined: Nov 2003
Posts: 1,257
What is stoping that is the my.tilt=0; in there. Also I wanted to add I've had personal issues keeping me out the loop recently. I hope to be back before too long.


Optimism is an occupational hazard of programming: feedback is the treament.
Kent Beck
Re: [Sub] Pathfinding [Re: Wade_Adams] #36285
03/23/05 22:10
03/23/05 22:10
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
Where's the problem with one dimensional arrays? As long as you use a binary heap there should be no problems.


Follow me on twitter
Re: [Sub] Pathfinding [Re: Wade_Adams] #36286
03/24/05 04:46
03/24/05 04:46
Joined: Feb 2005
Posts: 28
abetrader Offline
Newbie
abetrader  Offline
Newbie

Joined: Feb 2005
Posts: 28
The code you have in totorial1 is:
action patrol_path
{
var node_pos[3]; // temp storage for node position in AI
var node; // current node
var dist; // distance to node

// attach entity to nearest path
node = path_scan(me,my.x,my.pan,vector(360,180,1000));
if (node == 0) { beep();return; } // no path found

// find first waypoint
path_getnode(my,node,node_pos.x,null);


while (1)
{
// find distance
dist = vec_dist(node_pos.x,my.x);

// near target? Find next waypoint of the path
if (dist < 25) {
beep(); // you can comment this out is is nice for test though
node = path_nextnode(my,node,1);
path_getnode(my,node,node_pos.x,NULL);
}
vec_set(temp, node_pos.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);

my.tilt = 0; // I'm a maniac
temp.x = 5 * time;
temp.y = 0;
temp.z = 0;

c_move (my, temp, nullvector, IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE);

wait(1);
}
}

The code I marked in red is the movement code. How do I change it that if I set the node high up the enemey ship gos up? (I tried deleting my.tilt = 0; but it did not work.)
Also the line of code that turns the enemey towards the player(vec_to_angle(my.pan, temp)) makes the enemey ship snap into place, how do I make it rotate smoothly.

Thank you.

Re: [Sub] Pathfinding [Re: abetrader] #36287
03/26/05 07:26
03/26/05 07:26
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline
Serious User
jumpman  Offline
Serious User

Joined: Apr 2002
Posts: 1,246
ny
I dont think this has anything to do with pathfinding, but how about trying this for your tilt problem:

// create a vector skill beforehand

define target_angle,skill1;
define target_angle,skill2;
define target_angle,skill3;

// apply the target angle to the skills, not the entity itself

vec_set(temp, node_pos.x);
vec_sub(temp, my.x);
vec_to_angle(target_angle, temp);

//then apply the hover craft the new angles:

my.pan=target_angle.pan;
my.tilt=target_angle.tilt;

I think that should work.

(although this isnt helping to get off the tangent )

Re: [Sub] Pathfinding [Re: jumpman] #36288
03/28/05 01:15
03/28/05 01:15
Joined: Feb 2005
Posts: 28
abetrader Offline
Newbie
abetrader  Offline
Newbie

Joined: Feb 2005
Posts: 28
I had to use "var target_angle;" instead of the defines.

Besides for that it works great

Thank you.

Re: [Sub] Pathfinding [Re: abetrader] #36289
03/29/05 01:43
03/29/05 01:43
Joined: Oct 2003
Posts: 2,628
IL,US
FeiHongJr Offline
Expert
FeiHongJr  Offline
Expert

Joined: Oct 2003
Posts: 2,628
IL,US
if you want to use them as defines instead then use my.target_angle and so on in the functions instead of calling them like target_angle im not positive but a var might conflict if you have more then one ship in the level unless you declared them in the function then i dont think it would matter. this is just to my understanding of variables and their scope. so using them as defines is probally the best bet so that you can use them in as many functions as you want since it will point to that entitys skill instead of a global var. hope that makes sense


http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.
Re: [Sub] Pathfinding [Re: Wade_Adams] #36290
03/29/05 20:54
03/29/05 20:54
Joined: Mar 2005
Posts: 9
Vfx Offline
Newbie
Vfx  Offline
Newbie

Joined: Mar 2005
Posts: 9
Off-topic

Last edited by Doug; 03/30/05 05:39.
Re: [Sub] Pathfinding [Re: FeiHongJr] #36291
03/30/05 11:42
03/30/05 11:42
Joined: Feb 2005
Posts: 28
abetrader Offline
Newbie
abetrader  Offline
Newbie

Joined: Feb 2005
Posts: 28
I tried using skills but I am getting errors in lines:
my.pan =my.target_angle.pan;
my.tilt = my.target_angle.tilt;

Re: [Sub] Pathfinding [Re: abetrader] #36292
04/05/05 15:19
04/05/05 15:19
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
action patrol_path
{
var node_pos[3]; // temp storage for node position in AI
var node; // current node
var dist; // distance to node
var temp_angle[3];
var target_angle[3];
var temp_pan[3];
var rotation_speed = 6;
.
// get direction to target
vec_set(temp, node_pos.x);
vec_sub(temp, my.x);
vec_to_angle(temp_angle, temp);
.
// get difference of current angle to desired angle
target_angle.pan = ang(temp_angle.pan - my.pan);
target_angle.tilt = ang(temp_angle.tilt - my.tilt);
// move towards desired angle over time
temp_pan.pan = target_angle.pan * rotation_speed * time;
temp_pan.tilt = target_angle.tilt * rotation_speed * time;
temp_pan.roll = 0;
// must use c_rotate() to turn if using c_move()
c_rotate(my,temp_pan,IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE);
// move the entity
c_move (my, temp, nullvector, IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE);
.

That should be closer methinks.
Loco


Professional A8.30
Spoils of War - East Coast Games
Page 3 of 4 1 2 3 4

Moderated by  HeelX, Tobias_Runde 

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