|
Need Help Calling a Function / Help with multiple Actions?
#220077
08/06/08 00:16
08/06/08 00:16
|
Joined: Jul 2007
Posts: 48
MattyTheG
OP
Newbie
|
OP
Newbie
Joined: Jul 2007
Posts: 48
|
Hello everyone, I am working on this game where you shoot an airplane with a missile. Yea its pretty generic right now but I'm working on it haha. Let me put in my code before I go any further.
#include <acknex.h> #include <default.c>
var earthgravity[3]= 0,0, -386; var launch_angle= 45;
function missile_flying() { while (1) { my.roll = my.roll + 3; wait(1); } }
function main() { level_load ("PhysicsTest.wmb"); wait (2); while (1) { launch_angle += key_cuu * .05; launch_angle -= key_cud * .05; wait(1); } }
action ball_drop() { while (key_space == 0) {wait (1);} phent_settype(my, PH_Rigid, PH_box); phent_setmass (my, 2, PH_box); ph_setgravity (earthgravity); phent_addvelcentral(my, vector(0, -472 * cos(launch_angle) , 472 * sin(launch_angle) ) ); function missile_flying(); wait(1); }
action plane_fly() { while (key_space == 0) {wait (1);} phent_settype(my, PH_Rigid, PH_Box); phent_addvelcentral (my, vector(0, -472*cos(45), 0) ); }
Ok I have the code set up so that while the user is not pressing space, the action waits. Then when the spacebar is pressed the missile launches, as well as the plane.
The problem is that I want the missile to rotate, but if I put the my.roll = my.roll + 3; into the action ball_drop, it does not work. So I made it into a function and tried to call it when the missile launches.
I get an error saying empty function. I also want to work around the tilt modifier and what not, but it seems to be that I either have an action where the missile rolls, or one where it launches and can't get them to work simultaneously.
|
|
|
Re: Need Help Calling a Function / Help with multiple Actions?
[Re: MattyTheG]
#220079
08/06/08 00:21
08/06/08 00:21
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
in action ball_drop()
{
while (key_space == 0) {wait (1);}
phent_settype(my, PH_Rigid, PH_box);
phent_setmass (my, 2, PH_box);
ph_setgravity (earthgravity);
phent_addvelcentral(my, vector(0, -472 * cos(launch_angle) , 472 * sin(launch_angle) ) );
function missile_flying();
wait(1);
} delete the function missile_flying(); and replace it with just Hope this helps!
|
|
|
Re: Need Help Calling a Function / Help with multiple Actions?
[Re: MattyTheG]
#220086
08/06/08 00:45
08/06/08 00:45
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
unfortunately... the bits in game studio i use aren't A7 aren't physics and aren't planes and missiles :P couple of ideas though, when you call a new function you should really pass things through it in the parameters to make sure it's still calling the right entity, i'm not sure if A7 does/doesn't return errors for this,
action ball_drop()
{
while (key_space == 0) {wait (1);}
phent_settype(my, PH_Rigid, PH_box);
phent_setmass (my, 2, PH_box);
ph_setgravity (earthgravity);
phent_addvelcentral(my, vector(0, -472 * cos(launch_angle) , 472 * sin(launch_angle) ) );
missile_flying(me);
wait(1);
}
function missile_flying(localEnt)
{
me = localEnt;
while (1)
{
my.roll = my.roll + 3;
wait(1);
}
} try that? 2ndly, i don't know if playing with physics prevents you doing any other object manipulation? maybe someone else could answer that 3rdly, if your missile is symetrical all the way around, then you wouldn't necessarily see if .roll is working? try it's .tilt see if that makes it obvious just some suggestions but doubt they matter?
|
|
|
Re: Need Help Calling a Function / Help with multiple Actions?
[Re: cro_games]
#220120
08/06/08 01:01
08/06/08 01:01
|
Joined: Jul 2007
Posts: 48
MattyTheG
OP
Newbie
|
OP
Newbie
Joined: Jul 2007
Posts: 48
|
Yikes, now I can't even get the vertices to attach to a model. Mr Guest your suggestions did not help, but thank you very much for trying.
Ok I have my model, I selected bones mode, clicked create bone, and placed one in the middle of my missile. Next I selected vertices mode, selected all the vertices, and clicked attach, but none of them attached, they all stayed yellow.
Should I post this in MED help forum now?
BTW, should that ent_bonerotate go in the action right after the ball launches, or my new function that I am calling?
Thanks for the effort guys.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|