First Person
First Person
I want to implement a first person gun. Now is there a way to keep track of the camera position and move the weapon accordingly to keep it in front of the camera at the same spot at all times?
- Jeff Paddon
Undergraduate Research Assistant
Physics Department
St. Francis Xavier University
Undergraduate Research Assistant
Physics Department
St. Francis Xavier University
ok I understand what to do but I can't seem to find out how to assign a nod as the child of the camera node. I have been programming for a long time now, though I have only recently been introduced to classes...
- Jeff Paddon
Undergraduate Research Assistant
Physics Department
St. Francis Xavier University
Undergraduate Research Assistant
Physics Department
St. Francis Xavier University
Define a point in your player model called "Eyes". Attach the camera to this. Define a point on your player's hand called "RHand" or something like that. Attach your gun to this.
When your player walks, the camera should be animated automatically based on the "Eyes" node and the gun should also move based on the "RHand" node. You can choose to render the player model or not.
I think this is how Torque does it, and I think it's quite a nice design. Though I'm not an expert!
When your player walks, the camera should be animated automatically based on the "Eyes" node and the gun should also move based on the "RHand" node. You can choose to render the player model or not.
I think this is how Torque does it, and I think it's quite a nice design. Though I'm not an expert!
Code: Select all
//load gun and make it a child of the camera
scene::IAnimatedMesh* gun = smgr->getMesh("./data/gun.3ds");
scene::IAnimatedMeshSceneNode* gunnode = smgr->addAnimatedMeshSceneNode(gun);
gunnode->setParent(camera);
gunnode->setPosition(core::vector3df(72,-90,90));
gunnode->setScale( irr::core::vector3df(1,1,1));
gunnode->setRotation(core::vector3df(0,270,0));