attach a gun to the camera

Blitz3D Forums/Blitz3D Beginners Area/attach a gun to the camera

Braden(Posted 2008) [#1]
how do i attach a gun to the camera with out entityparent?
I want to have the camera start at a random position and I found out when it is in a new location, the gun doesn't follow...

any help?


Ross C(Posted 2008) [#2]
Parent the gun first then move the camera. :o)


Braden(Posted 2008) [#3]
um, I tried it and it didn't work... do you mean put the code above positionentity camera, or...where?

here is my code, if that helps...


thanks for the help


Mortiis(Posted 2008) [#4]
Camera = CreateCamera()

Weapon = LoadMesh(Weapon, Camera)
Positionentity, x, y, z



Braden(Posted 2008) [#5]
how would I do that and load the mesh?


Drak(Posted 2008) [#6]
Does your gun or guns even load? Will it work with two backslashes? If it does, just do what Mortiss said.

It's quite simple, really. Where it says:
weapon = loadmesh(weapon,camera)

Simply input the location of YOUR weapon you want loaded in place of the 2nd "weapon". So in your case, your weapon loading line of code would look like this:
Global gun = Loadmesh("guns\\w_fiveseven.3ds",camera)

Inputting the "camera" after the loading path parents it to the camera.

(Edit)
I just noticed you have your positionentity() call to the location of your gun commented out.


Ross C(Posted 2008) [#7]
To be more simplistic:


Set your graphics.
Create your camera.
Load your gun.
Position your gun where you want it to be, in relation to the camera.
Parent the gun to the camera.
Move the camera.

Everywhere your camera moves/rotates, the gun will stay in the exact same spot.


Braden(Posted 2008) [#8]
ok thanks, When I entityparent the gun to the camera, it is really close, I'm going to try and move it farther away from the camera, thanks