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: 3d laser beam  (Read 1775 times)

« Reply #15 on: April 24, 2011, 07:10:21 AM »
Sorry to say it Jess, but my coding skills are as bad as a bone... or whatever  ::)
Anyway, I used the link that was posted before to substract this piece of code. I think some of the lines are not needed, but I left them in the code, because it now simply works... And you can change the height to start and stop the line. Here it is (and all credits go to Jestermon):
Code: [Select]
int TARGET = OBJ_0;
int CAR = OBJ_22;
int LINE = OBJ_44;

void Main()
{
   Vector3 location;
   Quaternion orientation;
   Vector3 targetLocation;
   Vector3 direction;

   //set the arrow
   iObjectLocation(TARGET,targetLocation);      //get target locatiob
   iObjectLocation(CAR, location);              //get catr location
   location.y += 0;                             //set location 2m higher
   direction = targetLocation - location;       //get direction of targer
   iQuaternionLookAt(orientation,direction,Vector3(0,1,0)); //make rotation quat
 

   //set the line
   float length = iVectorLength(direction);     //get the length of direction
   location.y -=0;                              //make direction y 1m lower
   targetLocation.y +=0;                        //make target y 1m higher
   direction = targetLocation - location;       //get new direction
   iQuaternionLookAt(orientation,direction,Vector3(0,1,0)); //make quat from direction
   iObjectLocationSet(LINE,location);           //set line at 1m above car
   iObjectOrientationSet(LINE,orientation);     //rotate line to target
   iObjectScaleSet(LINE,Vector3(6,6,length));   //scale line = distance to target
}
FPS game creator for 3drad and >2000 games GamesAtNight

jestermon

« Reply #16 on: April 24, 2011, 07:35:35 AM »
.. but my coding skills are as bad as a bone...
I'm used to giving full answers wherever possible, not because I think the user does not know anything, but to make sure I leave nothing important out :D
Pages: 1 [2]