Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Konsti, AndrewAMD, 1 invisible), 1,376 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Why does it not fly? PLEASE HELP #222883
08/21/08 13:34
08/21/08 13:34
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline OP
Senior Member

Joined: Jan 2002
Posts: 454
Germany
Hello,
i'm using an cscript version of the throw object code from the wiki(for a bow code). The strange thing is that it works fine when I do not use a player/camera code. But when I want to use my player code and press the throw key, the arrow is created but stays motionless in the air.. please can somebody help me, what is the problem?
here is both the throwing code and the player script:

function Phy_debug_throw()
{

var flyvec[3];
vec_set(earthgravity, vector(0,0, -386));
while(1)
{
if(mouse_left)
{
you = ent_create("pfeil.mdl",camera.pos,NULL);
c_setminmax(you);


vec_set(you.pan,camera.pan);
ph_setgravity(earthgravity);


phent_settype(you,PH_RIGID,PH_BOX);
phent_setmass(you,2,PH_BOX);
phent_setelasticity(you,5,100);
phent_setfriction(you,60);
phent_setdamping(you,60,80);

flyvec[0] = 1;
flyvec[1] = 0;
flyvec[2] = 0;
vec_rotate(flyvec[0],camera.pan);

vec_scale(flyvec[0],300000);

phent_addcentralforce(you,flyvec[0]);

wait(-0.2);
}
wait(1);
}
}


Player script:




function camera_move()
{
while(player)
{
camera.pan += 0.5 * ang(player.pan - camera.pan);

vec_set(camera.x,player.x);
camera.z += 60; ///+ sin(total_ticks * 10);

mouse_mode = 0;


wait(1);
}
}



Action player_move()
{
var reldist[3];
var absdist[3];
var input_vec[3];
var Vz = 0;
var jump_able = 1;

my.invisible = on;

player = me;
camera_move();

while(me)
{


vec_set(reldist.x,nullvector);


input_vec.x = (key_w - key_s) * time * 30;
input_vec.y = (key_d - key_a) * time * -18;

my.pan -= 30 * mouse_force.x * time;
camera.pan = my.pan;
camera.tilt = min(max(ang(camera.tilt + 30 * mouse_force.y * time),-60),60);
Vz += (Vz == 0) * 100 * key_space * jump_able;

if(Vz > 0)
{
jump_able = 0;
}
Vz -= (Vz > 0);


c_move(me,input_vec,nullvector,GLIDE);
c_move(me,nullvector,vector(0,0,(Vz - 35) * time),0);
if(trace_hit)
{
jump_able = 1;
}


wait(1);
}
}

Last edited by CD_saber; 08/21/08 13:35.

Ja, lach du nur du haariges Pelzvieh!
Re: Why does it not fly? PLEASE HELP [Re: CD_saber] #223040
08/22/08 02:36
08/22/08 02:36
Joined: Aug 2007
Posts: 38
Pasadena, TX
Volund Offline
Newbie
Volund  Offline
Newbie

Joined: Aug 2007
Posts: 38
Pasadena, TX
I do an include player and include weapon and include camera in the main.c so they are all seperated and easily transfered to each game. Then in the weapon file i think you could use a c_trace to have the arrow go to your target, maybe event_shoot from the wiki
Also there are tutorials in AUM for each weapon type with examples.

Re: Why does it not fly? PLEASE HELP [Re: Volund] #223091
08/22/08 10:14
08/22/08 10:14
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline OP
Senior Member

Joined: Jan 2002
Posts: 454
Germany
Ok, thanks, but that cannot be the problem... without a camera script, it works just fine!


Ja, lach du nur du haariges Pelzvieh!
Re: Why does it not fly? PLEASE HELP [Re: CD_saber] #223251
08/22/08 22:13
08/22/08 22:13
Joined: Aug 2007
Posts: 38
Pasadena, TX
Volund Offline
Newbie
Volund  Offline
Newbie

Joined: Aug 2007
Posts: 38
Pasadena, TX
Well, so what your saying is that the player part works fine until you add this:


Code:
 function Phy_debug_throw() {
     var flyvec[3];
     vec_set(earthgravity, vector(0,0, -386));
     
          while(1) {
                  
               if(mouse_left) {
     	            you = ent_create("pfeil.mdl",camera.pos,NULL);
     	            c_setminmax(you); 
     	            vec_set(you.pan,camera.pan); 
    	            ph_setgravity(earthgravity);
     	            phent_settype(you,PH_RIGID,PH_BOX);
     	            phent_setmass(you,2,PH_BOX);
     	            phent_setelasticity(you,5,100);
     	            phent_setfriction(you,60);
     	            phent_setdamping(you,60,80);
     	            flyvec[0] = 1;
     	            flyvec[1] = 0;
     	            flyvec[2] = 0;
     	            vec_rotate(flyvec[0],camera.pan);
     	            vec_scale(flyvec[0],300000);
     	            phent_addcentralforce(you,flyvec[0]);
     	            wait(-0.2);
     	       } //END IF 
          } //END WHILE
     } //END FUNCTION 


But this works just fine by itself:

Code:
 function camera_move(){
     
     while(player){
     
          camera.pan += 0.5 * ang(player.pan - camera.pan);
          vec_set(camera.x,player.x);
          camera.z += 60; ///+ sin(total_ticks * 10);
          mouse_mode = 0;
          wait(1); 
     } //END WHILE
} //END FUNCTION

Action player_move(){
     var reldist[3];
     var absdist[3];
     var input_vec[3];
     var Vz = 0;
     var jump_able = 1;
     my.invisible = on;
     player = me;
     camera_move();
     
          while(me){
               vec_set(reldist.x,nullvector);
               input_vec.x = (key_w - key_s) * time * 30;
               input_vec.y = (key_d - key_a) * time * -18;
               my.pan -= 30 * mouse_force.x * time;
               camera.pan = my.pan;
               camera.tilt = min(max(ang(camera.tilt + 30 * mouse_force.y * time),-60),60);
               Vz += (Vz == 0) * 100 * key_space * jump_able;

                    if(Vz > 0){
                         jump_able = 0;
                    } //END IF
               
               Vz -= (Vz > 0);
               c_move(me,input_vec,nullvector,GLIDE);
               c_move(me,nullvector,vector(0,0,(Vz - 35) * time),0);

                    if(trace_hit){
                         jump_able = 1;
                    } //END IF
         
               wait(1);
          } //END WHILE 
     } //END ACTION 



Last edited by Volund; 08/22/08 22:15. Reason: cleaner code
Re: Why does it not fly? PLEASE HELP [Re: Volund] #223287
08/23/08 08:27
08/23/08 08:27
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline OP
Senior Member

Joined: Jan 2002
Posts: 454
Germany
The player script ALWAYS works fine, with AND without the throwing-code. The point is that the throwing code just doesn't work with the player code. When i just put the throwing code inside my script, and do not attach an action to the player (so that I use that default camera, after pressing "0") it works just fine...
Iam not able to understand why... with the player oode attached the arrow IS created but just stands still in the air (passable for some reason...). Is it possible that the WHILE-loop does not work for some reason?


Ja, lach du nur du haariges Pelzvieh!

Moderated by  HeelX, Spirit 

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