Hi, I am attempting to use the "SC_Raycast" command as a sub for shooting an actual object.
Here is my problem: I can return an object number for a cube I create, but, when I setup my enemy objects (which I use arrays for) raycast will not return on object number other than a really large number starting with 7. EDIT: The number that starts with 7 seems to return if nothing is intersected.
Here's my code for setting up my enemy objects:
Create_Enemies:
Rem <Creates Enemies>
For e = 1 to enemies
`Loads object and textures
Load image "Mediaimagemetal.jpg", 10+e
Load object "MediaobjEnemy.3DS", 10+e
`Setup Collisions for enemie
SC_SetupObject 10+e,1,0
`Texture enemies
Texture object 10+e,10+e
Set object speed 10+e,40
next e
Rem </Creates Enemies>
Goto _Loop
This code sets up a basic cube:
`Raycast media
Make object cube 110,100 : position object 110, 500,50,500
Sc_SetupObject 110,1,0
When I "shoot" or create a ray that intersects the above cube it returns the number "110" But I cannot return a number for the enemies when I "shoot" them. Here's my raycast code:
Raycast:
If mouseclick()
x1# = Object Position X( player )
y1# = Object Position Y( player )
z1# = Object Position Z( player )
Position Object 45, Object Position X( player ), Object Position Y( player ), Object Position Z( player )
Rotate Object 45, Object Angle X( player ), Object Angle Y( player ), Object Angle Z( player )
Move Object 45, 10000
x2# = Object Position X( 45 )
y2# = Object Position Y( 45 )
z2# = Object Position Z( 45 )
raycast = sc_RayCast( 0, x1#, y1#, z1#, x2#, y2#, z2#, 0 )
For i = 0 To raycast
ObjectHit = sc_GetObjectHit( hObj )
Next i
endif
Return
Does anyone have any ideas?? I'm guessing that the problem is because my enemies are created as arrays, but I don't have any clue how to fix this. I will post all my code if you guys want.
Thanks a lot!
ßõw§€r¥¤