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]

Author Topic: Who can Script?  (Read 790 times)

« on: September 02, 2011, 10:59:59 PM »
I'm not very good at scripting and for a while now i have been trying to edit this script so that the 1st person camera is stuck to a car:

Quote
//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,-2,0,0,"xyz");
      //Set locked SkinMesh location (camera relative)
      DeltaLocation = Vector3(0.1,-0.15,0.2);
   }
   iObjectOrientation(OBJ_22,cameraOrientation);
   iObjectLocation(OBJ_22,cameraLocation);
   Quaternion objectOrientation;
   Vector3 objectLocation;
   iQuaternionMultiply(objectOrientation,DeltaOrientation,cameraOrientation);
   iVectorRotate(objectLocation,DeltaLocation,cameraOrientation);
   objectLocation += cameraLocation;
   iObjectOrientationSet(OBJ_0,objectOrientation);
   iObjectLocationSet(OBJ_0,objectLocation);
}

-i need to be able to look around with the Camera but drive the car
-The camera needs to be attached to the car so that if i drive forward the camera goes with it

if anyone has a script that can do this or can tell me what to do it will be very helpful.
« Reply #1 on: September 02, 2011, 11:39:22 PM »
Here's what I tried without using a script:

Connect the car and Cam1stperson with a joint object. 'Fixed' seems to work well and fine tune as needed.

Don't link the cam to the g-force and make the movement (forwards, back, sideways) to zero to avoid any possible problems.

Just tested and works great.

EDIT: Link the car and cam for collisions too (unless you use a fixed joint) so the cam aint floppin' around everywhere.  :)  It'll take some tweaking to get perfect but should do what you need.
« Last Edit: September 03, 2011, 12:16:13 AM by Iowegian »
Game tip of the year: Just give up!! :D
« Reply #2 on: September 03, 2011, 01:41:26 AM »
I've been working on that for once. Didn't really finish it though. And I believe I deleted the test project previous week. Let me just make a little something.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #3 on: September 03, 2011, 01:48:45 AM »
Here it is.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #4 on: September 03, 2011, 03:53:21 AM »
Great thanks guys. i dont work with joints oftern so i never thought of using one
« Reply #5 on: September 03, 2011, 11:06:37 AM »
you don't need to script a cam to keep it inside (or at any spot) on a car... try using a chase cam, link it to the car.... set the movement and rotations to 1... and adjust one of the angles to 0.6  (i think... i'm not anywhere near my machine right now so can't test, sorry)...

--Mike
« Reply #6 on: September 03, 2011, 11:08:33 AM »
It's not about keeping it inside. It's about looking around.

I suppose.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #7 on: September 03, 2011, 11:10:48 AM »
you can look around real easy too... again, i'm not at my machine so...

or...

you can use Jestermon's LocalToParent() function and not link the car... real easy script...

--Mike
« Last Edit: September 03, 2011, 11:15:41 AM by Mike Hense »
« Reply #8 on: September 03, 2011, 06:15:39 PM »
Dont worry its good now.
i can look around while the car drives
thanks again
Pages: [1]