How do Blitz3D assigns work?

Blitz3D Forums/Blitz3D Programming/How do Blitz3D assigns work?

Blitz can use the target variable in an expression. I suspect your source and target entities are at the exact same position so the EntityDistance() returned is 0.

As you can't divide by 0, you need to add some checking before using divide:

Magnitude# = EntityDistance(source,target)
If Magnitude > 0
Magnitude = 1/Magnitude
Else
; do something else
End If

Or make a function to suit your needs:

Function div#(a#,b#)
If b=0.0 Return a#
Return a/b
End Function


Duckstab: No need to assign cube1 & cube2 as Globals in that case.

Cya!
Tom