PositionEntity & EntityType Behaviour

Blitz3D Forums/Blitz3D Programming/PositionEntity & EntityType Behaviour

semar(Posted 2003) [#1]
Hi all,

I have a question.

To move an entity, there's MoveEntity. The movement of an entity is affected by collisions, if set.

So, to place an entity in an arbitrary point in the 3D world, without being affected by collisions, there is the command PositionEntity, right ?

So, with PositionEntity I can place the entity in any place in the world, even if from the start position x,y,z and the final position x1,y1,z1 there's some obstacle.

Am I right, or am I missing something here ?

Then, run the example below, and move the EntityType command before or after the PositionEntity command (both for the sphere).

You will see that when EntityType is placed after positionentity, then the sphere will be correctly placed at the left side of the 'wall'.

Instead, when the EntityType command is used before the positionentity one, then the sphere will remain at 0,0,0.

Could someone enlight me if this is a correct behaviour ?

Thanks,
Sergio.

P.S.
Using B3D 1.83
;code ===========================================================
Graphics3D 640,480,0,2

Const E_GROUND = 1
Const E_OBJECT = 2

Global camera = CreateCamera()
CameraRange camera,0.1,1000
PositionEntity camera,0,0.5,-5

cube = CreateCube()
tex = CreateTexture(32,32)
SetBuffer TextureBuffer(tex)

Color 255,0,0
Rect 0,0,30,30
 
Color 255,255,255
Text 0,10,"WALL"

SetBuffer BackBuffer()
EntityTexture cube,tex


;EntityColor cube,200,0,0
ScaleEntity cube,0.6,0.6,3
PositionEntity cube,-1,0,0
EntityType cube, E_GROUND ;assign entity type ground to the 'wall'


Collisions E_OBJECT,E_GROUND,2,1 ;set up collisions between object type and ground type

sphere = CreateSphere() ;this creates a sphere at 0,0,0

scale# = 0.3
ScaleEntity sphere,scale,scale,scale

EntityColor sphere,0,200,0
EntityRadius sphere,scale

;if you move this entitytype statement AFTER the positionentity one, then the sphere will be correctly placed
EntityType sphere,E_OBJECT

;when Entitytype is before this statement, the sphere will remain at 0,0,0
PositionEntity sphere,-4, 0, 0 

While Not KeyDown(1)

UpdateWorld
RenderWorld

Text 0,0,"Sphere position: " + EntityX(sphere) + " ; " + EntityY(sphere) + " ; " + EntityZ(sphere) Flip

Wend

End

;end code ====================================================================================



Rob Farley(Posted 2003) [#2]
The way understand it... You need to hideentity before moving it with any command to avoid collisions.


GitTech(Posted 2003) [#3]
Or use ResetEntity after PositionEntity/MoveEntity/etc.


semar(Posted 2003) [#4]
Cheers Dr Av and GitTech.

So PositionEntity is affected by collisions too.

Ok, this is an important info for me, since I thought it worked in a different manner.

Thanks again,
Sergio.


DJWoodgate(Posted 2003) [#5]
Or use entitytype with a collision type of zero before updateworld.


semar(Posted 2003) [#6]
Right DJWoodgate, but then I have to set EntityType again after UpdateWorld.

I've just tryed with resetentity after positionentity and it works fine.

:)


BlackJumper(Posted 2003) [#7]
**BINK!**

[Lightbulb goes on over Blackjumper's head]

Aaaaah ! That is very useful information - solves a problem I had been wrestling with... Worth including in any TopTips archives !!

{And please don't turn this thread into another Skitchy/Ravey flamewar just because Lightbulb was mentioned ;-) }


semar(Posted 2003) [#8]
solves a problem I had been wrestling with

Don't tell it to me !!

I'm doing a FPS - the sequel of Dangerous Robots - but this time it's played in a 3D level.

Last night I've implemented the shooting for the robot.

Well, it indeed shoots, but the bullets started often from 0,0,0 instead of the robot's position.

Each bullet is created at 0,0,0 (the createsphere creates always at 0,0,0).

Then I need to position the bullet at the robot position..

Fact is, the bullet has its EntityType already set, as well the collision between the bullet and the level, which will stop the bullet.

So if I place the bullet, using PositionEntity, from the created position 0,0,0, to another position xR,yR,zR, so that travelling between 0,0,0 and xR,yR,zR the bullet does not collide with the level mesh, then the bullet is correctly placed at xR,yR,zR, that is, the robot coordinates.

But if the robot is around a corner, or in another room... then guess what ? The robot indeed shoots, but the bullet is fired from 0,0,0.. ARGH !

Now not more, thanks to ResetEntity after Positionentity.

But hey, it has driven me mad until I figured out !!!

Aaah... the 'Joy' of Programming... GGRRRRRRR !!!

=)

Sergio.