Post by NicusorN5 on Feb 19, 2015 15:38:00 GMT
First Person Shooter Script
Network Client Script:
Network Game Script:
SpeedOMeter Script
____________________________________________________________________________________________________________
Hope i helped you
-NicusorN5
//This script keeps a SkinMesh object locked
//at a given offset from the camera.
//This technique can be used in a FPS game, to
//render view-locked 3d props, like a carried gun.
//Link this script object to the CamChase object
//and the SkinMesh object.
//Do NOT link the CamChase and the SkinMesh in the Object List!
//In this script, make sure that:
// OBJ_0 is the CamChase object
// OBJ_3 is the SkinMesh object
Quaternion DeltaOrientation;
Vector3 DeltaLocation;
void Main()
{
Quaternion cameraOrientation;
Vector3 cameraLocation;
Quaternion orientation;
Vector3 location;
if (iInitializing())
{
//Set locked SkinMesh orientation (camera relative)
iQuaternionFromEulerAngles(DeltaOrientation,0,0,0,"xyz");
//Set locked SkinMesh location (camera relative)
DeltaLocation = Vector3(1,-0.3,1);
}
iObjectOrientation(OBJ_0,cameraOrientation);
iObjectLocation(OBJ_0,cameraLocation);
Quaternion objectOrientation;
Vector3 objectLocation;
iQuaternionMultiply(objectOrientation,DeltaOrientation,cameraOrientation);
iVectorRotate(objectLocation,DeltaLocation,cameraOrientation);
objectLocation += cameraLocation;
iObjectOrientationSet(OBJ_3,objectOrientation);
iObjectLocationSet(OBJ_3,objectLocation);
}
Network Client Script:
//Network connection example, client project
//A string generated on the server is sent to all connected clients.
//Before launching this project, launch its server counterpart (the
//NetworkStringServer.3dr project) on another PC in the network.
//Then launch this project, specify the IP address for the server
//machine and click the 'Search' button. When the remote 'game' is
//found, click Join to connect.
//If everything works as expected, you should see the yellow fishes
//dance the same way as the server project's balls.
//You can also launch both the server and the client projects on
//the same PC by using the local IP address. In this case, though,
//at least one of the two projects must be compiled because you
//can't launch two instances of the 3D Rad editor on the same PC.
bool NetworkActive = false;
void Main()
{
if (iInitializing())
{
//Activate the client network system.
if (iNetClientStart("","Player",123456789,100000,"Join Game",-1,0))
{
NetworkActive = true;
}
}
if (iDeinitializing())
{
//De-activate the client network system.
iNetStop();
NetworkActive = false;
}
}
Network Game Script:
//Network connection example, server project
//A string created on the server is sent to all connected clients
//Launch this project on the server PC. See client project script
//for additional information.
float SendTimer = 0;
bool NetworkActive = false;
void Main()
{
if (iInitializing())
{
//Activate the server network system.
if (iNetServerStart("3D Rad Network Game","Server",25857,123456789,100000))
{
NetworkActive = true;
}
}
if (iDeinitializing())
{
//De-activate the client network system.
iNetStop();
NetworkActive = false;
}
}
SpeedOMeter Script
//This script adjusts a sprite orientation runtime depending
//on the car's speed. Useful to implement, for example, a
//rotary-dial-based speedomenter
void Main()
{
Quaternion spriteOrientation;
float zero = 110; //gauge position when speed is zero
float range = 6; //gauge range (in degrees) for each meter per second
iQuaternionFromEulerAngles(spriteOrientation,0,0,zero-IN_3*range,"xyz");
iObjectOrientationSet(OBJ_0,spriteOrientation);
}
____________________________________________________________________________________________________________
Hope i helped you
-NicusorN5