Jump to content

Recommended Posts

Posted

I had a few questions about doing bullet raycasting.

 

I have a gun, whose position and range I know. How do I do a raycast in a straight line from the gun? What I'm really meaning to ask is, if the player is turned sideway, what value should I increment so that the raycast is performed in a straight line from the players perspective?

 

 

Also, the Pick will return a Pick Object which will have a TEntity object in it. I recall a long time ago that it was possible to create a pointer to my coded classes (for enemies and whatnot) using , I think, Object userdata. Does anyone know how this works?

 

 

Basically I want to be able to trace if what was hit with the raycast, and if its a AI type, reduce its health. If its a wall, etc, create a bullet hole texture.

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Posted

Anyone here?

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Posted

I would like some help on this too. I have a gun set up with sound effect and muzzleflash, but how to fire bullets????????

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted
Also, the Pick will return a Pick Object which will have a TEntity object in it. I recall a long time ago that it was possible to create a pointer to my coded classes (for enemies and whatnot) using , I think, Object userdata. Does anyone know how this works?

That would require something like:

 

class MyCube
{
public:
   MyCube()
   {
       m_entity = CreateCube();
       SetEntityUserData(m_entity, static_cast<BP>(this));
   }
private:
   TEntity m_entity;
};

 

and then, once you know the picked entity:

 

MyCube& pickedCubeInstance = *(reinterpret_cast<MyCube*>(GetEntityUserData(pick.entity)));

untested, but this is the concept

 

I agree, this should rather be posted in the programming section.

 

As for the first question, if your game is a FPS, just use CameraPick from the middle of the screen.

If not, use a LinePick starting at the weapon model origin and ending at the point (0,0,<weaponrange>) relative to the weapon, converted to global coordinates using

TFormVector.

Posted

That would require something like:

 

class MyCube
{
public:
   MyCube()
   {
       m_entity = CreateCube();
       SetEntityUserData(m_entity, static_cast<BP>(this));
   }
private:
   TEntity m_entity;
};

 

and then, once you know the picked entity:

 

MyCube& pickedCubeInstance = *(reinterpret_cast<MyCube*>(GetEntityUserData(pick.entity)));

untested, but this is the concept

 

I agree, this should rather be posted in the programming section.

 

As for the first question, if your game is a FPS, just use CameraPick from the middle of the screen.

If not, use a LinePick starting at the weapon model origin and ending at the point (0,0,<weaponrange>) relative to the weapon, converted to global coordinates using

TFormVector.

 

 

Thanks for that, TFormVector is what I was looking for. Just a quick question, how do I determine the position of the center of the screen?

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Posted

GraphicsWidth()/2, GraphicsHeight()/2

 

I meant the 3D position of the center of the screen.

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Posted
I meant the 3D position of the center of the screen.

WHAT??? This doesn't exist.. Your screen is 2d :)

Well i think you mean how to transform from 2d to 3d pos right? Check CameraProject , CameraUnproject .

Also wich language you need? We could help you better if we know the language.

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...