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
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 14,141 guests, and 5 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
Page 2 of 2 1 2
Re: calculating vec_dist as part of an action [Re: Quad] #325756
05/27/10 23:40
05/27/10 23:40
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
gameaddict Offline OP
Junior Member
gameaddict  Offline OP
Junior Member

Joined: Apr 2010
Posts: 59
Lagos, Nigeria
Thanks! that stoppped the crash, now I'll try implementing it in other functions.


I know I can.
Re: calculating vec_dist as part of an action [Re: gameaddict] #325757
05/27/10 23:50
05/27/10 23:50
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
what I said from the beginning, its a null pointer crash.

Always check entities if they are there, before using them.

Re: calculating vec_dist as part of an action [Re: gameaddict] #325759
05/28/10 00:09
05/28/10 00:09
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
gameaddict Offline OP
Junior Member
gameaddict  Offline OP
Junior Member

Joined: Apr 2010
Posts: 59
Lagos, Nigeria
Thanks! it works. but the function crashes when I press any button. Please take a look at my functions, I must be doing something wrong. I've tried different things but they cause more or less the same result.

The action:

Code:
action theBall()
{
	while(!player) wait(1);
	
   set(my, SHADOW);
	
	phent_settype(my, PH_RIGID, PH_SPHERE);
	phent_setmass(my, 1, PH_SPHERE);
	phent_setfriction(my,90);
	phent_setelasticity(my,75,100);
	phent_setdamping(my,30,5);
	phent_addvelcentral(my,vector(10,10,0));
	ph_setgravity(vector(0,0,-500));
	
	my.emask |= ENABLE_FRICTION;
	
   	while(1){
   		dist = vec_dist(my.x, player.x);
        if(key_w || key_a || key_s || key_d){
        	move_with_ball();
        	}
   		
   	 
		
		if(key_x){
			kick();
		}
		wait(1);
	}
 }



The function:

Code:
function move_with_ball()
{

while(!my) wait(1);


while(1){
if(dist <= 20){
		proc_mode = PROC_LATE;
      my.x = player.x + 15 * cos(player.pan);
      my.y = player.y + 15 * sin(player.pan);
      my.z = player.z - 15;
      my.pan=player.pan;
      my.roll+=2;
      my.tilt+=2;
}
	if(key_x){
		kick();
	}

}
wait(1);
}



Thanks.


I know I can.
Re: calculating vec_dist as part of an action [Re: gameaddict] #325762
05/28/10 00:22
05/28/10 00:22
Joined: Apr 2010
Posts: 265
V
Vinous_Beret Offline
Member
Vinous_Beret  Offline
Member
V

Joined: Apr 2010
Posts: 265
Quote:
function move_with_ball()
{

while(!my) wait(1);


while(1){
if(dist <= 20){
proc_mode = PROC_LATE;
my.x = player.x + 15 * cos(player.pan);
my.y = player.y + 15 * sin(player.pan);
my.z = player.z - 15;
my.pan=player.pan;
my.roll+=2;
my.tilt+=2;
}
if(key_x){
kick();
}

}
wait(1);
}

"wait(1)" is outside while loop, try this:
Click to reveal..
function move_with_ball()
{

while(!my) wait(1);


while(1){
if(dist <= 20){
proc_mode = PROC_LATE;
my.x = player.x + 15 * cos(player.pan);
my.y = player.y + 15 * sin(player.pan);
my.z = player.z - 15;
my.pan=player.pan;
my.roll+=2;
my.tilt+=2;
}
if(key_x){
kick();
}
wait(1);
}
}


Re: calculating vec_dist as part of an action [Re: gameaddict] #325763
05/28/10 00:23
05/28/10 00:23
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
The 'wait(1)' is outside of the while loop in the 'movr_with_ball' function.

Re: calculating vec_dist as part of an action [Re: DJBMASTER] #326609
06/01/10 19:58
06/01/10 19:58
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
gameaddict Offline OP
Junior Member
gameaddict  Offline OP
Junior Member

Joined: Apr 2010
Posts: 59
Lagos, Nigeria
Thanks guys, it worked! The only problem is that when I call the kick function, the ball is kicked from it's original position and not from where the player has moved to. I've not been able to figure out how to update the original ball position so it doesn't move to it's original position before been kicked. Could someone help me out?


I know I can.
Page 2 of 2 1 2

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