Waffe positionieren
Übersicht

MerierBetreff: Waffe positionieren |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hallo Leute!
Ich habe eine Frage: Also in meinem Programm kann ich meine Kamera so drehen wie ich möchte in jede richtung. So nun habe ich aber auch noch eine waffe die immer genau vor der kamera sein soll. wie macht man soetwas? Ich habe schonmal was ausprobiert aber das klappt nicht: sorry für den schlechten code^^ Code: [AUSKLAPPEN] Graphics3D 640,480,0,2 Global Pist = 10 Cam = CreateCamera() Keller = LoadMesh("Keller-G1.x") PositionEntity Keller,200,-1,100 ScaleEntity Keller,80,85,80 EntityType Keller,2 Sperr = CreateCube() Sperr2 = CreateCube() PositionEntity Sperr2,290,3,100 PositionEntity Sperr,290,2,100 EntityAlpha Sperr,0 ScaleEntity Sperr2,50,0.1,20 FlipMesh Sperr2 ScaleEntity Sperr,100,0.1,200 ;FlipMesh Sperr EntityType Sperr,3 Gun = LoadAnimMesh("gun.b3d") GunR = LoadAnimMesh("gun_reload.b3d") GunRel = LoadAnimSeq(GunR,"gun_reload.b3d") GunCol = LoadAnimSeq(Gun,"gun_col.b3d") ScaleEntity GunR,0.02,0.02,0.02 ScaleEntity Gun,0.02,0.02,0.02 textgun = LoadTexture("Gun.png") EntityTexture Gun,textgun EntityTexture GunR,textgun RotateEntity Gun,0,160,0 RotateEntity GunR,0,160,0 PositionEntity Cam,190,1,100 EntityType Cam,1 EntityRadius Cam,1.9 HideEntity GunR piv = CreatePivot(Cam) PositionEntity piv ,200,-1,100 Repeat PointEntity Gun,Cam dx#=EntityX( piv,True )-EntityX( Gun ) dy#=EntityY( piv,True )-EntityY( Gun ) dz#=EntityZ( piv,True )-EntityZ( Gun ) TranslateEntity Gun,dx*.1,dy*.1,dz*.1 RotateEntity Cam,EntityPitch(Cam)+MouseYSpeed(),EntityYaw(Cam)-MouseXSpeed(),0 MoveMouse 400,250 Collisions 1,2,2,2 Collisions 1,3,2,2 If KeyDown(200) MoveEntity Cam,0,0,0.1 EndIf If KeyDown(208) MoveEntity Cam,0,0,-0.1 EndIf If MouseHit(1) Pist = Pist -1 Animate Gun,3,1,0 EndIf If Pist = 0 HideEntity Gun ShowEntity GunR Pist = 10 Animate GunR,3,0.5,0 EndIf If Animating( GunR ) = 0 HideEntity GunR ShowEntity Gun EndIf PositionEntity GunR, EntityX(Cam)+0.5,EntityY(Cam)-0.8,EntityZ(Cam)+1 PositionEntity Gun, EntityX(Cam)+0.5,EntityY(Cam)-0.8,EntityZ(Cam)+1+EntityRoll(Cam) If KeyDown(203) MoveEntity Cam,-0.1,0,0 EndIf If KeyDown(205) MoveEntity Cam,0.1,0,0 EndIf UpdateWorld() RenderWorld() Flip Until KeyHit(1) End Hoffe auf schnelle Antwort^^ |
||
![]() |
Tankbuster |
![]() Antworten mit Zitat ![]() |
---|---|---|
Erst erstellst du die Kamera, dann erstellst du die Waffe.
Dann verschiebst du die Waffe mit MoveEntity etwas nach Vorne (Also MoveEntity Waffe,0,0,5) Als letztes musst du die Waffe nurnoch per EntityParent an die Kamera hängen, damit sie alle Bewegungen der Kamera mitmacht. Fertig ![]() PS: Zur Not könntest du auch sowas in die Hauptschleife packen: (ich denke, die Variablen erklären sich von selbst) Code: [AUSKLAPPEN] PositionEntity Waffe,cam_x,cam_y,cam_z
RotateEntity Waffe,cm_pitch,cam_yaw,cam_roll MoveEntity Waffe,0,0,5 |
||
Twitter
Download Jewel Snake! Windows|Android |
Merier |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Danke für die schnelle Antwort!
Jetzt ist aber die Waffe falsch herrum und ich kann sie nicht drehen |
||
![]() |
The_Nici |
![]() Antworten mit Zitat ![]() |
---|---|---|
Du solltest sie aber drehen können. Oo
RotateEntity ![]() ![]() MfG |
||
Merier |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Das hab ich ja schon drinn aber die Waffe wird jetzt falsch herrum angezeigt
Code: [AUSKLAPPEN] Graphics3D 640,480,0,2 Global Pist = 10 Cam = CreateCamera() Keller = LoadMesh("Keller-G1.x") PositionEntity Keller,200,-1,100 ScaleEntity Keller,80,85,80 EntityType Keller,2 Sperr = CreateCube() Sperr2 = CreateCube() PositionEntity Sperr2,290,3,100 PositionEntity Sperr,290,2,100 EntityAlpha Sperr,0 ScaleEntity Sperr2,50,0.1,20 FlipMesh Sperr2 ScaleEntity Sperr,100,0.1,200 ;FlipMesh Sperr EntityType Sperr,3 Gun = LoadAnimMesh("gun.b3d") GunR = LoadAnimMesh("gun_reload.b3d") GunRel = LoadAnimSeq(GunR,"gun_reload.b3d") GunCol = LoadAnimSeq(Gun,"gun_col.b3d") ScaleEntity GunR,0.02,0.02,0.02 ScaleEntity Gun,0.02,0.02,0.02 textgun = LoadTexture("Gun.png") EntityTexture Gun,textgun EntityTexture GunR,textgun RotateEntity Gun,0,160,0 RotateEntity GunR,0,160,0 PositionEntity Cam,190,1,100 EntityType Cam,1 EntityRadius Cam,1.9 HideEntity GunR Licht = CreateLight(2) PositionEntity Licht,EntityX(Cam),EntityY(Cam),EntityZ(Cam) LightColor Licht,255,255,255 LightRange Licht,2 EntityFX Gun,1+8 Repeat PositionEntity Gun,EntityX(Cam),EntityY(Cam),EntityZ(Cam) RotateEntity Gun,EntityPitch(Cam),EntityYaw(Cam),EntityRoll(Cam) MoveEntity Gun,0,0,2 RotateEntity Cam,EntityPitch(Cam)+MouseYSpeed(),EntityYaw(Cam)-MouseXSpeed(),0 MoveMouse 400,250 Collisions 1,2,2,2 Collisions 1,3,2,2 If KeyDown(200) MoveEntity Cam,0,0,0.1 EndIf If KeyDown(208) MoveEntity Cam,0,0,-0.1 EndIf If MouseHit(1) Pist = Pist -1 Animate Gun,3,1,0 EndIf If Pist = 0 HideEntity Gun ShowEntity GunR Pist = 10 Animate GunR,3,0.5,0 EndIf If Animating( GunR ) = 0 HideEntity GunR ShowEntity Gun EndIf PositionEntity GunR, EntityX(Cam)+0.5,EntityY(Cam)-0.8,EntityZ(Cam)+1 If KeyDown(203) MoveEntity Cam,-0.1,0,0 EndIf If KeyDown(205) MoveEntity Cam,0.1,0,0 EndIf UpdateWorld() RenderWorld() Flip Until KeyHit(1) End |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group