entitycollided doesnt return an int; returns an entity handle?

Started by William, May 14, 2023, 09:33:52

Previous topic - Next topic

William

different from blitz3d, im trying to convert some code here.

this is a bit of code im trying to convert into openb3d/blitzmax

Local CollidedCollidable:Int = EntityCollided(PlayerCollider,GroupEnvironment)
 If( CollidedCollidable = 0 )
  PlayerIsOnGround = False
 ElseIf( CollidedCollidable <> 0 )
  PlayerIsOnGround = True
 EndIf

but instead of a int or boolean value it returns an entity instead of an int as in b3d. is there a workaround for this?
I'm just a mentally ill person stuck in person. I've had quite an online history and of media such as role plays with people that became movies (for real) among other things and content. I wanted to be an online famous person at one time. Unfortunately it's ill and I'm anonymous.

William

scaremonger messaged a workaround on discord:
Local CollidedCollidable:TEntity = EntityCollided(PlayerCollider,GroupEnvironment)
 If( Not CollidedCollidable )
  PlayerIsOnGround = False
 Else
  PlayerIsOnGround = True
 EndIf

i will work on this section of code and test it. later.
EDIT: GWRON fixed it, it remains to be fully tested however.
I'm just a mentally ill person stuck in person. I've had quite an online history and of media such as role plays with people that became movies (for real) among other things and content. I wanted to be an online famous person at one time. Unfortunately it's ill and I'm anonymous.

Midimaster

No! The EntityCollided() return the Entity which collided! In human words: It tells you who you bumped into!

So it is a base for a IF-branch:

If EntityCollided(PlayerCollider, GroupEnvironment) = GroundMesh
     PlayerIsOnGround = True
EndIf

Of course you can go the way via a local variable. but this is only necessary, if you want to check more than one possible collision.

Example:
Local WhoCollided:TEntity = EntityCollided(PlayerCollider,GroupEnvironment)

If WhoCollided=GroundMesh
     print "Player is on ground "
ElseIf WhoCollided=Player2
     print "both Players both collided"
ElseIf WhoCollided=Enemy
     print "Crash with enemy"
Else
    print "no collision happened"
EndIf
...back from North Pole.