Schusscollision

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

 

Stani

Betreff: Schusscollision

BeitragMi, Mai 26, 2010 19:26
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo Leute,hab hier schon viel im Forum rummgesucht,aber nicht dazu gefunden.

Ich hab eine Schussfunction,die bei Mausklick jede 500ms eine Kugel schießt.

Wenn ich in der Function nach der Collision frage (if entitycollided(locSchuss\Entity,2) Then....)
passiert iwie nichts.

Auch mit meshesintersect gehts nicht,wobei noch ein Fehler kommt.

Hier mein Code:
Code: [AUSKLAPPEN]
Function Schuss()

If MouseDown(1) Then


If S < MilliSecs() Then
S = MilliSecs() + 500

locSchuss.SchussTyp = New SchussTyp
locSchuss\Entity=CopyEntity(Kugel,Waffe)
EntityColor locSchuss\Entity,30,30,200
EntityFX locSchuss\Entity,1
TurnEntity locSchuss\Entity ,0,0,90
MoveEntity locSchuss\Entity,.2,10,0
EntityParent locSchuss\Entity,0
EndIf
EndIf


For locSchuss = Each SchussTyp
    MoveEntity locSchuss\Entity ,0,-.1,0

    If EntityCollided(locSchuss\Entity,2)  Then
    Delay 1000
    EndIf

    Next



End Function

Xeres

Moderator

BeitragMi, Mai 26, 2010 19:39
Antworten mit Zitat
Benutzer-Profile anzeigen
Du musst noch einen EntityRadius festlegen Idea
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)
 

Stani

BeitragMi, Mai 26, 2010 19:49
Antworten mit Zitat
Benutzer-Profile anzeigen
Also hab jetzt noch bei new Schuss....... entityradius locSchuss\Entity ,3 gemacht aber bringt auch nichts

Xeres

Moderator

BeitragMi, Mai 26, 2010 19:56
Antworten mit Zitat
Benutzer-Profile anzeigen
EntityType fehlt noch - UpdateWorld/Collisions nicht vergessen.
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)
 

Stani

BeitragMi, Mai 26, 2010 19:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Also jetzt nochmal der Code(der ganze)

Code: [AUSKLAPPEN]
Graphics3D 1280,1024,32,1
SetBuffer BackBuffer()
HidePointer



Global cam=CreateCamera()
CameraRange cam,0.2,10000
Global light=CreateLight()
Global plane=LoadBSP("Map1.bsp")
Global cube=CreateCube()
ScaleEntity cube,3,3,3
ScaleEntity plane,0.1,0.1,0.1
EntityTexture plane,LoadTexture("wiese.jpg")

PositionEntity plane,0,0,0
PositionEntity cam,0,1,0

Global Waffe=LoadMesh("tris.3ds",cam)
EntityTexture Waffe,LoadTexture("skin.jpg")
TurnEntity Waffe,-90,90,0
ScaleMesh Waffe,0.044,0.044,0.044
MoveEntity Waffe,1.2,1.2,-1


EntityType cam,1
EntityRadius cam,2
EntityType plane,2
EntityType cube,3

Collisions 1,2,2,2

Global Kugel=CreateCylinder()
ScaleMesh Kugel,.5,1,.5


Type SchussTyp
    Field Entity
End Type

MoveMouse 640,512

Global S#

While Not KeyDown(1)
Cls

Schuss()

PositionEntity cam,EntityX(cam),4,EntityZ(cam)

RotateEntity cam,EntityPitch(cam)+MouseYSpeed(),EntityYaw(cam)-MouseXSpeed(),0


If KeyDown(200) Then MoveEntity Waffe,.1,0,0
If KeyDown(208) Then MoveEntity Waffe,0,.1,0


If KeyDown(17) Then MoveEntity cam,0,0,.3
If KeyDown(31) Then MoveEntity cam,0,0,-.3
If KeyDown(30) Then MoveEntity cam,-.3,0,0
If KeyDown(32) Then MoveEntity cam,.3,0,0





RenderWorld
UpdateWorld





Flip
Wend
End



Function Schuss()

If MouseDown(1) Then


If S < MilliSecs() Then
S = MilliSecs() + 500

locSchuss.SchussTyp = New SchussTyp
locSchuss\Entity=CopyEntity(Kugel,Waffe)
EntityColor locSchuss\Entity,30,30,200
EntityFX locSchuss\Entity,1
TurnEntity locSchuss\Entity ,0,0,90
MoveEntity locSchuss\Entity,.2,10,0
EntityParent locSchuss\Entity,0


EndIf
EndIf


For locSchuss = Each SchussTyp
    MoveEntity locSchuss\Entity ,0,-.1,0
    EntityRadius locSchuss\Entity,3
   
    If EntityCollided(locSchuss\Entity,3)  Then
    Print "treffer"
    EndIf

    Next

End function



Xeres

Moderator

BeitragMi, Mai 26, 2010 20:06
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich empfehle konstanten um Kollisionstypen lesbarer zu machen.
- EntityRadius kannst du gleich hinter CopyEntity einfügen, dass muss nur einmal aufgerufen werden.
- Du prüfst ob die Kugeln mit Kollisionstyp 3 Zusammenprallen, dazu muss du a) die Kollisions mit colissions aktivieren, und b) brauch die Kugel dann den entsprechenden EntityType.
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group