Weapon Model sticking into the ground
Blitz3D Forums/Blitz3D Programming/Weapon Model sticking into the ground
| ||
I have a weapon model attached to the player and whenever you look down with the camera it sticks into the ground. This is probably really easy to solve, but i have no idea how to fix this. |
| ||
Can you post the code? |
| ||
weapon1=LoadMesh("M4.3ds",camera) ScaleEntity weapon1,.5,.5,.5 RotateEntity weapon1,0,90,0 MoveEntity weapon1,1.8,-.8,-1 |
| ||
Maybe it has something to do with collision? If you even have it.. |
| ||
Maybe this can help ? http://www.blitzbasic.com/codearcs/codearcs.php?code=1271 bless :) |
| ||
I guess the wepon is too big. Just scale it smaller, then move it closer to the camera. In extreme cases you have to scale the Z-Axis a lil shorter because of the lense distortion. This method however also prevents the weapon from sticking into the walls. |
| ||
Oh I thought you were talking about not being able to get the gun out of the wall because it's stuck. |
| ||
this works better: weapon1=LoadMesh("M4.3ds",camera) ScaleEntity weapon1,meshwidth(weapon1)/4,meshheight(weapon1)/4,meshdepth(weapon1)/4 ;divide by 2 for possible better results RotateEntity weapon1,0,90,0 MoveEntity weapon1,1.8,-.8,-1 |
| ||
Just create a second camera, parent the gun to it, and sync the rotation of the camera to that of your main camera to get correct lighting on the gun. EXAMPLE: Creating the second camera. To sync the rotation use the code below, or something similar. RotateEntity HUD_camera, EntityPitch# ( user_x_pivot_handle, True ), EntityYaw# ( user_handle, True ), 0.0, True Where HUD_camera is the handle to the second camera; user_x_pivot_handle is the handle to a pivot used for the pitch of the player's head (FPS view); and user_handle is the handle to the main entity used for the player, which is yawed. |
| ||
of you could just say entityorder gun,-1 ??? This always fixes my problems |
| ||
An Entityorder <> 0 disables polygon z-ordering. This works fine for quads but for a detailed mesh it looks terrible. |
| ||
Um...That seems a bit complicated. I would just render the gun after everything else. Like this: The above code will render the world before the gun, so no matter what, the gun will never stick through the floor (or any world geometry). |
| ||
The above code will render the world before the gun, so no matter what, the gun will never stick through the floor (or any world geometry). You're right. That code wouldn't show the gun sticking through the world geometry. It wouldn't show any world geometry at all, as you haven't set CameraClsMode to disable clearing the background. Also, all that hiding and showing would likely cause problems with interpolation if render tweening was being used for game speed regulation. Basically, what you're trying to do is equivalent to using a second camera, but with the added overhead of hiding every entity in the world for each render frame. Here's a practical example of using the second camera approach with a 2 metre long gun. Note that the second camera doesn't introduce any significant additional overhead, as it's just rendering the gun - as would be done if the gun were rendered by the main camera. |