Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,473 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Npc on path doesnt work #351204
12/22/10 18:27
12/22/10 18:27
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
I tryed to move an entity over a path with smooth turning (i dont want to use spline from manual) but after a while it doesnt work anymore...it has something to do with angles but i dont know how to fix it, can someone help? smile

Code:
action PLAYER_PATH()
{
	VECTOR move_me;
	VECTOR target_node_pos;
	
	ANGLE temp_turn;
	
	var temp;
	var target_node_num = 1;
	
 
   path_set(me,"path_player");
	path_nextnode(my,1,1);
	path_getnode(me,target_node_num,target_node_pos.x,NULL);
	
	set(me,PASSABLE | INVISIBLE);
	
	wait(1);
	
	while(1)
	{
		camera.x = my.x;
		camera.y = my.y;
		camera.z = my.z;
		camera.pan = my.pan;
		camera.tilt = my.tilt;
		camera.roll = my.roll;
		
		/////////////////////////////////////////////////////////////////////
		//////							Path instructions							//////
		/////////////////////////////////////////////////////////////////////
		
		//get target node position and put into target_node_pos		
		if(!path_getnode(me,target_node_num,target_node_pos.x,NULL))
		{
			target_node_num = 1;
		}
		
		//if close to target node, take next node as target
		if(vec_dist(my.x,target_node_pos.x) < 150)
		{
			target_node_num += 1;
		}
  		
		vec_set(temp,target_node_pos.x);
  		vec_sub(temp,my.x);
  		vec_to_angle(temp_turn.pan,temp);
		
  		if(my.pan < temp_turn.pan)
  		{
  			my.pan += (abs(my.pan-temp_turn.pan) / 10);
		}
		else
		{
			my.pan -= (abs(my.pan-temp_turn.pan) / 10);
		}
		
		if(my.tilt < temp_turn.tilt)
  		{
  			my.tilt += (abs(my.tilt-temp_turn.tilt) / 10);
		}
		else
		{
			my.tilt -= (abs(my.tilt-temp_turn.tilt) / 10);
		}
  		
		move_me.x = 25 * (key_shift+1) * time_step;
		
		c_move(me,vector(move_me.x,0,0),nullvector,GLIDE | IGNORE_PASSABLE);
		
		wait(1);
	}
}



Re: Npc on path doesnt work [Re: Toon] #351266
12/23/10 04:06
12/23/10 04:06
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
Maybe someone has an example of this...im trying to move an entity over a path with smooth turning to its next node.. grin anyone?

Re: Npc on path doesnt work [Re: Toon] #351267
12/23/10 04:18
12/23/10 04:18
Joined: Jul 2010
Posts: 129
B
bk9iq Offline
Member
bk9iq  Offline
Member
B

Joined: Jul 2010
Posts: 129
I am not 100% sure of what u want but if u mean moving an object along a path why don't u try the :
ent_movepath (ENTITY* ent, char* pathname, var speed,var mode)
first u need to include "entmove.c" from script libraries which comes with 3DGS...
There's an example of this in the manual ....
Hope that helps....

Re: Npc on path doesnt work [Re: bk9iq] #351283
12/23/10 10:30
12/23/10 10:30
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
bk9iq ent_movepath also uses path_spline


3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: Npc on path doesnt work [Re: painkiller] #351303
12/23/10 14:32
12/23/10 14:32
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
but after a while it doesnt work anymore...

You do not explain what's not working anymore and what the problem looks like. (except for angles)

A wild guess: Replace
Code:
if(my.pan < temp_turn.pan)
  		{
  			my.pan += (abs(my.pan-temp_turn.pan) / 10);
		}
		else
		{
			my.pan -= (abs(my.pan-temp_turn.pan) / 10);
		}
		
		if(my.tilt < temp_turn.tilt)
  		{
  			my.tilt += (abs(my.tilt-temp_turn.tilt) / 10);
		}
		else
		{
			my.tilt -= (abs(my.tilt-temp_turn.tilt) / 10);
		}


with
Code:
my.pan += ang(temp_turn.pan-my.pan)*0.1*time_step;
my.tilt += ang(temp_turn.tilt-my.tilt)*0.1*time_step;




"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Npc on path doesnt work [Re: bk9iq] #351308
12/23/10 15:01
12/23/10 15:01
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
I cant find anything about this in the manual...is it A8 code?

Re: Npc on path doesnt work [Re: Toon] #351318
12/23/10 16:44
12/23/10 16:44
Joined: Jul 2010
Posts: 129
B
bk9iq Offline
Member
bk9iq  Offline
Member
B

Joined: Jul 2010
Posts: 129
@painkiller: I am sorry I didn't know that...
@Toon: Yes It is A8 Code... I don't know why but it is not in the online manual... anyway I am sorry coz as painkiller said it uses path_spline so it doesn't work for what u want... sorry

Re: Npc on path doesnt work [Re: bk9iq] #351873
12/29/10 03:27
12/29/10 03:27
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
What I want (:D) is actually quite simple, it's just an entity moving over a path making smooth turns at it's corners... I tryed so many times / things eek and I still can't get it to work tongue

Re: Npc on path doesnt work [Re: Toon] #351875
12/29/10 05:13
12/29/10 05:13
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Have you tried my code?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Npc on path doesnt work [Re: Superku] #351906
12/29/10 14:34
12/29/10 14:34
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
Yes but it has the same problem frown It makes turns untill it's past 360 degrees and acts weird after that... I tryed stuff with the ang() instruction to but without any luck grin

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