2 registered members (TipmyPip, 1 invisible),
18,789
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Help me stop ball disappearing
#326930
06/03/10 19:35
06/03/10 19:35
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
I've been trying to figure this out but the solution is not forthcoming. My ball keeps disappearing to it's original location whenever I break the movement loop. It's supposed to still be at the player's feet when I call the pass() of shot() functions but instead, it returns to it's original position first. In fact, while moving, I am unable to move if I am at the original location because collision detection with the ball is taking place. I have to turn to move to other locations with the ball. Please is there a way I can update the real ball position to the current x, y and z locations or how can I implement it in the current while loop. Any help or advice is greatly appreciated. Here are the codes:
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));
//dcam();
my.emask |= ENABLE_FRICTION;
while(1){
if((key_w || key_a || key_s || key_d) && vec_dist(my.x, player.x) <= 20){
move_with_ball();
}
wait(1);
}
}
The ball movement:
function move_with_ball()
{
while(my == NULL) wait(1);
while(1){
proc_mode = PROC_LATE;
vec_set(my.x,vector(player.x + 13 * cos(player.pan),player.y + 13 * sin(player.pan), player.z - 12));
my.roll+=20;
my.tilt+=20;
if(key_x){
pass();
break;
}
if(key_space){
shot();
break;
}
if(key_1){
break;
}
wait(1);
}
}
I know I can.
|
|
|
Re: Help me stop ball disappearing
[Re: gameaddict]
#326957
06/03/10 20:16
06/03/10 20:16
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi!
Your wait (1) is outside the while. Place inside.
sorry it's ok
Last edited by Ottawa; 06/03/10 20:18.
Hope this helps! Ottawa  Ver 7.86.2 Pro and Lite-C
|
|
|
Re: Help me stop ball disappearing
[Re: Ottawa]
#327022
06/04/10 07:31
06/04/10 07:31
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
The code is working but how to update original ball position so it doesn't disappear from players feet first before it calls the pass() or other functions?
I know I can.
|
|
|
Re: Help me stop ball disappearing
[Re: gameaddict]
#327023
06/04/10 08:24
06/04/10 08:24
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
try something like this:
phent_settype(my, 0, 0);
vec_set(my.x,vector(player.x + 13 * cos(player.pan),player.y + 13 * sin(player.pan), player.z - 12));
my.roll+=20;
my.tilt+=20;
phent_settype(my, PH_RIGID, PH_SPHERE);
|
|
|
Re: Help me stop ball disappearing
[Re: MasterQ32]
#327118
06/04/10 17:49
06/04/10 17:49
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
Thanks! It's no longer disappearing but the ball is always pushing the player backwards whether moving or not. If I remove the my.roll parts, It moves the player along the z axis. I tried setting gravity again inside the loop but it didn't help.
I know I can.
|
|
|
Re: Help me stop ball disappearing
[Re: MasterQ32]
#327274
06/05/10 16:24
06/05/10 16:24
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
Thanks. I've remove it but the ball is still moving the player upwards and the ball is really slow when I call my pass or shot function. How can I stop the upwards movement? Here's my edited function:
function move_with_ball()
{
while(my == NULL) wait(1);
while(1){
proc_mode = PROC_LATE;
phent_settype(my, 0, 0);
vec_set(my.x,vector(player.x + 13 * cos(player.pan),player.y + 13 * sin(player.pan), player.z - 12));
phent_settype(my, PH_RIGID, PH_SPHERE);
if(key_x){
pass();
break;
}
if(key_space){
shot();
break;
}
if(key_1){
break;
}
wait(1);
}
}
my pass function:
function pass()
{
VECTOR vPass;
vPass.x = 3; vPass.y = 0; vPass.z = 0.5;
vec_rotate(vPass, player.pan);
phent_addvelcentral(my, vPass);
}
I know I can.
|
|
|
Re: Help me stop ball disappearing
[Re: gameaddict]
#327277
06/05/10 16:44
06/05/10 16:44
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
can you post you players function?? because i think i know where your mistake is, but i must see the players code before, add to you balls action
action theBall()
{
set(me,POLYGON);
c_setminmax(me);
i don't know if it works, but maybe
|
|
|
Re: Help me stop ball disappearing
[Re: MasterQ32]
#327288
06/05/10 17:44
06/05/10 17:44
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
It's still moving upwards. Here are the codes: player:
action player_action()
{
while(1){
player = me;
if(key_1 || key_x || (key_x && vec_dist(my.x, player.x) <= 20)){
wait(1);
rot_player(); //change player
}
handle_movement();
handle_gravity();
handle_animation(1);
wait(1);
}
}
ball action:
action theBall()
{
while(!player) wait(1);
//set(my, SHADOW);
set(me,POLYGON);
c_setminmax(me);
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){
if((key_w || key_a || key_s || key_d) && vec_dist(my.x, player.x) <= 20){
move_with_ball();
}
wait(1);
}
}
the ball movement:
function move_with_ball()
{
while(my == NULL) wait(1);
while(1){
proc_mode = PROC_LATE;
phent_settype(my, 0, 0);
vec_set(my.x,vector(player.x + 13 * cos(player.pan),player.y + 13 * sin(player.pan), player.z - 12));
phent_settype(my, PH_RIGID, PH_SPHERE);
if(key_x){
pass();
break;
}
if(key_space){
shot();
break;
}
if(key_1){
break;
}
wait(1);
}
}
Thanks.
I know I can.
|
|
|
Re: Help me stop ball disappearing
[Re: gameaddict]
#327317
06/05/10 20:45
06/05/10 20:45
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
i think you you the c_***-functions in this two:
handle_movement();
handle_gravity();
try to set FLAG2 of the ball and use the IGNORE_FLAG2 - Option in you c_***-functions i think this would work
|
|
|
|