Shard Posted April 20, 2010 Posted April 20, 2010 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. Quote 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
Shard Posted April 20, 2010 Author Posted April 20, 2010 Anyone here? Quote 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
Dealman Posted April 20, 2010 Posted April 20, 2010 Maybe you'd get better luck by posting in the Materials, Textures, & Shaders and/or Programming Quote Currently learning the basics of the Leadwerks Editor.
cassius Posted April 20, 2010 Posted April 20, 2010 I would like some help on this too. I have a gun set up with sound effect and muzzleflash, but how to fire bullets???????? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
Masterxilo Posted April 20, 2010 Posted April 20, 2010 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. Quote Hurricane-Eye Entertainment - Site, blog.
Shard Posted April 21, 2010 Author Posted April 21, 2010 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? Quote 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
Masterxilo Posted April 21, 2010 Posted April 21, 2010 GraphicsWidth()/2, GraphicsHeight()/2 Quote Hurricane-Eye Entertainment - Site, blog.
Shard Posted April 21, 2010 Author Posted April 21, 2010 GraphicsWidth()/2, GraphicsHeight()/2 I meant the 3D position of the center of the screen. Quote 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
Joh Posted April 21, 2010 Posted April 21, 2010 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. Quote Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.
Recommended Posts
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.