Thanks for the sugestions. I made a parent field in my type. When my CreateBall function is called the Ball\parent is set to 0. However I am not sure what specific syntax to use to this field to parent in the following section of my update function.
If EntityCollided(instance\Entity , CT_GRAB)
EndIf
I have tried to put lines of code like:
EntityParent instance\entity, catcher,1
and a lot of other variations but to no avail.
Here is a stripped down version of my script
If EntityCollided(instance\Entity , CT_GRAB)
EndIf
I have tried to put lines of code like:
EntityParent instance\entity, catcher,1
and a lot of other variations but to no avail.
Here is a stripped down version of my script
Graphics3D 640, 480, 0, 2 SeedRnd MilliSecs() Const CT_BALL = 1 Const CT_CONVEYOR = 2 Const CT_GRAB = 3 Collisions CT_BALL , CT_CONVEYOR , 2 , 2 Collisions CT_BALL , CT_GRAB , 2 , 0 Type Ball Field Entity Field x# , y# , z# Field xs# , ys# , zs# Field r , g , b End Type FrameTimer = CreateTimer(60) StartTime = MilliSecs() cam = CreateCamera() PositionEntity cam,25.5,15.3,-1.5 TurnEntity cam,18.75,0,0 lite = CreateLight() ;--------- "conveyor belt" ----------------- conveyor = CreateCube() PositionEntity conveyor,6,11, 70 ScaleEntity conveyor,2,2,40 RotateEntity conveyor,-30,0,0 EntityType conveyor,CT_CONVEYOR EntityColor conveyor , 225 , 225 , 0 ;--------- the "mechachincal arm" the ------------ ;--------- real version is made of meshes -------- armbase =CreateCube() PositionEntity armbase,-6,20,94 ScaleEntity armbase,4,1,4 RotateEntity armbase,0,90,0 armPivot_low = CreatePivot() PositionEntity armPivot_low,-6,20,94 arm_lower =CreateCube(armPivot_low) ScaleEntity arm_lower,.5,6,.5 PositionEntity arm_lower,0,7,0 ;--- this is the part of the arm that "Grabs" the balls------- Global catcher = CreateCube(arm_lower) ScaleEntity catcher,10,1,1 PositionEntity catcher,0,1,0 EntityType catcher,CT_GRAB EntityAlpha catcher,.5 ;========================================= ;------------MY "MAIN" LOOP--------------- ;========================================= Repeat ;------------- arm animation stuff--------- Angle = Angle + 2 negAngle = negAngle - 2 If Angle > 359 Then Angle = 0 : negAngle = 0 RotateEntity armPivot_low,0,0,Sin(negAngle) * 60 entity = CameraPick (cam, MouseX (), MouseY ()) ;----------- Ball Stuff --------------------------------- UpdateBalls(0.025) ;--------- Everytime the timer ticks at 1 or less create a ball ----------- frame=MilliSecs()/.1 Mod 200 If (frame <1) CreateBall() EndIf ;----------------START OF CAM CONTROLS---------------- ;--------- I can move the camera using the arrow keys- ;-------------- and the "e" and "d" keys ------------- vert#=0 horz#=0 zoom#=0 If KeyDown( 208 )=True Then vert#=-.25 If KeyDown( 200 )=True Then vert#=.25 If KeyDown( 203 )=True Then horz#=-.25 If KeyDown( 205 )=True Then horz#=.25 If KeyDown( 32 )=True Then zoom#=-.25 If KeyDown( 18 )=True Then zoom#=.25 MoveEntity cam,horz#,vert#,zoom# UpdateWorld RenderWorld ;--------- keeps the FPS rate ---------- sysFpsTimer2# = MilliSecs() sysFps = 1.0 / ( (sysFpsTimer2 - sysFpsTimer1 ) / 1000.0) sysFpsTimer1 = sysFpsTimer2 WaitTimer(FrameTimer) Flip Until KeyHit (1) End ;==================================================== Function UpdateBalls(Gravity#) For instance.Ball = Each Ball If Not instance = Null instance\x# = instance\x# + instance\xs# instance\z# = instance\z# + instance\zs# instance\ys# = instance\ys# - Gravity# instance\y# = instance\y# + instance\ys# ;----------- When the Ball Collides with the ------------------- ;----------- coveyor stop falling and move in------------------- ;----------- the -z direction ------------------- If EntityCollided(instance\Entity ,CT_CONVEYOR) ;Not EntityCollided(instance\Entity , CT_ARM) instance\ys# = Abs(instance\ys# / 1.08) instance\zs# = .15 EndIf ;---------- !!! HELP THIS PART IS NOT WORKING !!! --------------- ;---------- if the catcher makes collides with the ball --------------- ;---------- the catcher becomes parent to the ball --------------- If EntityCollided(instance\Entity , CT_GRAB) EntityParent instance\entity, catcher,1 instance\xs# = 0 instance\x# = instance\x# + instance\xs# instance\ys# = 0 instance\y# = instance\y# + instance\ys# instance\zs# = 0 instance\z# = instance\z# + instance\zs# EndIf PositionEntity(instance\Entity , instance\x# , instance\y# , instance\z#) If instance\y# < -10 FreeEntity instance\Entity Delete instance EndIf EndIf Next End Function ;==================================================== Function CreateBall() Ball.Ball = New Ball Ball\Entity = CreateSphere() EntityType(Ball\Entity , CT_BALL) ScaleEntity(Ball\Entity , 1.5 , 1.5 , 1.5) EntityRadius(Ball\Entity , 1.5) EntityShininess(Ball\Entity , 5.0) ;origin position of the Balls Ball\x# = 6.1 Ball\y# = 4.8 Ball\z# = 44.9 Repeat ;direction and speed of the Balls move Ball\xs# = 0 Ball\ys# = 0 Ball\zs# = .011 Until (Ball\zs# > 0.01 Or Ball\zs# < -0.01) ;randomize the color of the Balls Ball\r = Rnd(255) Ball\g = Rnd(255) Ball\b = Rnd(255) EntityColor(Ball\Entity , Ball\r , Ball\g , Ball\b) End Function ;====================================================