| We hope you enjoy your visit. You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you are already a member please log in to your account to access all of our features: |
| First person gun | |
|---|---|
| Tweet Topic Started: Jun 19 2006, 02:01 PM (455 Views) | |
| terra | Jun 19 2006, 02:01 PM Post #1 |
|
Member
![]() ![]() ![]() ![]()
|
How do i make my weapon stick to the camera's rotation and position? I use this in step: x = camera.x; y = camera.y; z = camera.z + 1; rotx = camera.rotx; roty = camera.roty; rotz = camera.rotz; but that makes the gun 'fly' around camera. I need it to perfectly stick to the fixed camera view. I am using the gm6 from Starter Kit. |
![]() |
|
| Despellanion | Jun 19 2006, 03:07 PM Post #2 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
|
![]() |
|
| Zip | Jun 19 2006, 03:10 PM Post #3 |
|
Forum Leader
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I think you have to use sin & cos to place the model wherever you want respectively to the camera. A hint: Use little gun's models and place them very near to the camera. With this trick the gun will not penetrate the walls and other objects in front of you. Miracles of perspective! |
|
Sorry if i've made some errors, I'm not english! | |
![]() |
|
| terra | Jun 19 2006, 04:10 PM Post #4 |
|
Member
![]() ![]() ![]() ![]()
|
That makes a similar effect to what i made, there is a lag in weapon's position. When i move the camera, the weapon starts moving in advance and dissapears off the view a little. We had sin/cos in school, but i have no clue how to apply that in 3d world. |
![]() |
|
| Dr. Best | Jun 19 2006, 05:13 PM Post #5 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Timing is important .
|
![]() |
|
| terra | Jun 19 2006, 06:10 PM Post #6 |
|
Member
![]() ![]() ![]() ![]()
|
But i did..
|
![]() |
|
| Dr. Best | Jun 20 2006, 12:07 AM Post #7 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
This line is the root of all evil. You've got to write the following instead:
This is important. Else it won't work. If your model isn't positioned correctly then you have to change it's position in your modelling editor. |
![]() |
|
| terra | Jun 20 2006, 12:28 PM Post #8 |
|
Member
![]() ![]() ![]() ![]()
|
It still does not work correctly, when i press up button the model dissappears and then reappears when i stop. |
![]() |
|
| Dr. Best | Jun 20 2006, 01:45 PM Post #9 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
In your code you took out the Step() call that's contained in the original piece of code. Probably that's the reason. So just put Step(); at the end of the block that belongs to the with statement. |
![]() |
|
| terra | Jun 20 2006, 07:20 PM Post #10 |
|
Member
![]() ![]() ![]() ![]()
|
Step(); is included in model's step event. |
![]() |
|
| Dr. Best | Jun 20 2006, 09:49 PM Post #11 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I know but it comes too late there. If you want your gun to be at the right place when it's rendered you've got to call Step at this position. That's kinda exception. |
![]() |
|
| terra | Jun 21 2006, 12:46 AM Post #12 |
|
Member
![]() ![]() ![]() ![]()
|
ok thx, that finally fixed it Btw, in the example of u3d, which part is responsible for raising z value upon changes in terrain height? So when u can go upwards when the terrain is slope |
![]() |
|
| Dr. Best | Jun 21 2006, 01:16 PM Post #13 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
The call to collision_model does this. |
![]() |
|
| terra | Jun 21 2006, 05:23 PM Post #14 |
|
Member
![]() ![]() ![]() ![]()
|
but how does it make it go up and down.. if u put in my staircase model's collision event with camera, the camera will just stop somewhere in the middle of the model. |
![]() |
|
| « Previous Topic · Questions about Ultimate 3D · Next Topic » |





![]](http://z1.ifrm.com/static/1/pip_r.png)



.
10:34 AM Jul 11