3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1] 2

Author Topic: Trick counter- flips, rolls, 360's, 2 wheeling- need a scriptor  (Read 2782 times)

« on: October 05, 2009, 02:15:52 PM »
I'm planning out a stunt mode for my game and I need some ideas on how to script something like this:

only start the trick counter when the car is in mid air

if car X rotation > 360        then         add 50 points to trick score
if car Y rotation > 180        then         add 75 points and double the current trick score
if car Z rotation > 180        then         add 125 points and triple the current trick score

When the car finally comes in contact with the ground record the trick score to the main score.

There's also a two wheeling trick which should be easier to script:

If wheels in contact < 2
then
Add 5 points every .3 second to the trick score
else
stop giving points and record the trick score to main score


Something like this anyway....I'm thinking of releasing this sort of game mode in the beta if we can get something like this to work. Also, if you think you can help, I'll post a physics test project you can script in.

I'm sorry this is quite a lot to ask for, but even some small scripting ideas will get this closer to what I'll need.

-Rush3fan
« Reply #1 on: October 07, 2009, 09:33:17 PM »
There's also a two wheeling trick which should be easier to script:

If wheels in contact < 2
then
Add 5 points every .3 second to the trick score
else
stop giving points and record the trick score to main score

ok, you need to add an EventOnContact object and link it to the ground and each wheel (one EventOnContact per wheel) of the car, for this you select the wheel of the car like when you select it to attach the skinmesh wheel.
now you know when the wheels are in contact with the ground, and the script would be:
Code: [Select]
if (IN_eventOnContact < 1) { //the wheel is not touching the ground }
so, I dont know if you want to add points when the car is doing a wheelie (running only on the rear wheels) or every time only two wheels are touching the ground.

in the first case you would monitor the front wheels:
Code: [Select]
if (IN_eventOnContactLeftFrontWheel < 1 && IN_eventOnContactLeftFrontWheel < 1) { //sum points }
in the second one you should use an aux var that count how many wheels are touching the ground and sum +1 for every wheel in contact with the ground:
Code: [Select]
wheelsTouchingGround=0;
if (IN_eventOnContactLeftFrontWheel > 0) { wheelsTouchingGround++; }
if (IN_eventOnContactRightFrontWheel > 0) { wheelsTouchingGround++; }
if (IN_eventOnContactLeftRearWheel > 0) { wheelsTouchingGround++; }
if (IN_eventOnContactRightRearWheel  > 0) { wheelsTouchingGround++; }
if (wheelsTouchingGround == 2) { //sum points }

to sum points, 5 every .3 seconds would be something like 0.25 for each script cycle, so //sum points would be something like:
Code: [Select]
score+=0.25;
if you want to sum points for each trick and sum those points to the total score when each trick ends then you need to use an aux var than is false when you are not making a trick and true when you are. when this var is false you need to check if trickScore > 0, and if so, then is because you just finished a trick and earned some points, so you gonna sum 'em to the totalScore+=trickScore and reset the score = 0
« Last Edit: October 08, 2009, 01:17:58 AM by loop »
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!
« Reply #2 on: October 07, 2009, 11:20:35 PM »
Dude! That's awesome! Thanks so much... The 2wheel trick can be a wheeli or 2wheeling sideways. This is giving me even more ideas. I'll see what I can make with this.
« Reply #3 on: October 08, 2009, 03:41:03 AM »
very nice trick system! ;D
« Reply #4 on: January 17, 2010, 11:50:07 PM »
Wow! this is pretty old now... But I think I have enough scripting rescources to get this finished!
But here's the problem I'm trying to figure out:
{
if (z > 90)
iObjectStart(OBJ_154);
}

With OBJ_154 being the counter object, how do I only execute the comand once? So each roll is counted as 1 pt. ?
« Reply #5 on: January 18, 2010, 07:32:56 AM »
bool trickDone=false;

then...

{
if (z > 90 && !trickdone) {
   iObjectStart(OBJ_154);
   trickDone=true;
}
}

and you have to set trickDone=false again when ... I dont know, when z is 0 again? when the trick is done and is time to count another one.
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!
« Reply #6 on: January 18, 2010, 10:14:11 AM »
Z starts from 0 to 180 switches to -180 and back to 0 making a full 360 roll. Basically, I want to add one point every time it rolls.
But in some cases if I set it to:
{
if (z > 170)
iObjectStart(OBJ_154);
}
The script doen't have enough time to catch that roll because the Rb spins really fast.
Thats why 90 seems like a good number to work with for now.
I tried the script and seems to set the counter once but then stops counting any additional rolls. :-\
« Reply #7 on: January 18, 2010, 10:19:20 AM »
Here's the full script.
Code: [Select]
//OBJ_154 is the Counter
//OBJ_22 is the RigidBody
//OBJ_0 is the Skinmesh
Vector3 location;
Quaternion orientationR;
Quaternion orientationM;
float offset=0;
float x;
float y;
float z;
string xyz="xyz";
bool trickDone=false;

void Main()

{
if (z > 90 && !trickDone) {
   iObjectStart(OBJ_154);
   trickDone=true;
}

   //set location
   iObjectLocation(OBJ_22,location);
   iObjectLocationSet(OBJ_0,location);

   //set orientation
   iObjectOrientation(OBJ_22,orientationR);
   iQuaternionToEulerAngles(orientationR,x,y,z);
   x += offset;
   iQuaternionFromEulerAngles(orientationM,x,y,z,xyz);
   iObjectOrientationSet(OBJ_0,orientationM);
}
« Reply #8 on: January 19, 2010, 01:29:06 PM »
I need another variable to work with; that is, "Clockwise" (true or false).
Like I said earlier: This confuses me because the rotation starts at 0 and goes to either 180 or -180, making a full circle.
Any Ideas?

Ok, new question:
Code: [Select]
Vector3 location;
Quaternion orientationR;
Quaternion orientationM;
float offset=0;
float x;
float y;
float z;
string xyz="xyz";
float Currentangle = 0;
float Getangle = 0;
int count = 0;
bool Clockwise = false;

void Main()
{
{
{
{
if (Currentangle > Getangle) Clockwise = true;
else
Clockwise = false;
}
{
Currentangle = z;
if (count == 2) Getangle = Currentangle;
count++;
}
}
{
OUT_44=z;
OUT_154=Getangle;
OUT_132=Currentangle;
   //set location
   iObjectLocation(OBJ_22,location);
   iObjectLocationSet(OBJ_0,location);

   //set orientation
   iObjectOrientation(OBJ_22,orientationR);
   iQuaternionToEulerAngles(orientationR,x,y,z);
   x += offset;
   iQuaternionFromEulerAngles(orientationM,x,y,z,xyz);
   iObjectOrientationSet(OBJ_0,orientationM);
}



{

if (Clockwise = true)
iObjectShow(OBJ_66);
else
iObjectHide(OBJ_66);



}
}
}


Ok, this is my first attempt, but I'm not sure how I can make Getangle= Currentangle every.2 seconds. Any help Please?
 



« Last Edit: January 19, 2010, 02:35:06 PM by Rush3Fan »
« Reply #9 on: January 20, 2010, 12:11:42 PM »
Ok, I got a clockwise, counterclockwise detector working. But it only detects changes around 0 degrees.

First off, does anyone know how to make a timer in a script? So I don't need two external ones?

Be sure to check out the projec to understand how it works.

Sorry for the tripple post, but this is so confusing and I need help.

Oh.. one more question: Should I use bool clockwise = false; as a variable I can read and write?

« Reply #10 on: January 20, 2010, 06:25:13 PM »
sounds like somethiing i could use for my game...
however, when I try to open the project, 3dRad crashes! any help? :o
CsharpJsharp.com: the computer nerd site. Accepting suggestions!




Windows 7 on Acer Aspire 5735 laptop
Pentium Dual-Core T3200
732 MB Mobile Intel Graphics Accelerator 4500M
2GB DDR2 RAM
« Reply #11 on: January 20, 2010, 08:19:46 PM »
Yea, it's probably because it was made with version 6.42..
But anyway, it's not ready to use in a game yet, but if you can help me improve it, I could go remake it on a different computer with version 6.40.
« Reply #12 on: January 20, 2010, 08:31:27 PM »
I'll try to help you.
I really love the idea. s far I've been using eventonlocation to score things which doesnt work well. thanks!
CsharpJsharp.com: the computer nerd site. Accepting suggestions!




Windows 7 on Acer Aspire 5735 laptop
Pentium Dual-Core T3200
732 MB Mobile Intel Graphics Accelerator 4500M
2GB DDR2 RAM
« Reply #13 on: January 20, 2010, 08:43:32 PM »
Do you have version 6.40? Give me a few mins and I'll have it posted....

Sorry, that took forever. see if this works. It still has a little bug in it.. I'll try to fix it here...
Edit: Ok fixed!
« Last Edit: January 20, 2010, 09:24:04 PM by Rush3Fan »
« Reply #14 on: January 20, 2010, 08:56:52 PM »
yes I do. thanks! I at least want to see if this script works and then try to improve it if I can. ;D
CsharpJsharp.com: the computer nerd site. Accepting suggestions!




Windows 7 on Acer Aspire 5735 laptop
Pentium Dual-Core T3200
732 MB Mobile Intel Graphics Accelerator 4500M
2GB DDR2 RAM
Pages: [1] 2