This is really a mystery

Blitz3D Forums/Blitz3D Beginners Area/This is really a mystery

Jack(Posted 2005) [#1]
I have been trying to work out collision detection for sprites and got some help from DJ but must admit I didn't really understand.

So,I've been doing the following.As an example for a tree I will create a cone,sphere,cylinder,whatever. with alpha 0.
TRY to get it to lineup in the center of the sprite.Shouldn't be hard - wrong.

Relevent code:

pinetree=CreateCone(4)
pinetrunk=CreateCube()
ScaleEntity pinetree,25,25,25
ScaleEntity pinetrunk,2,10,2
EntityType pinetree,type_ground
EntityType pinetrunk,type_ground
RotateEntity pinetree,0,45,0
PositionEntity pinetree,40,38,-460
PositionEntity pinetrunk,40,5,-460
EntityAlpha pinetree,0
EntityAlpha pinetrunk,0
EntityParent pinetree,pinetrunk

trees=CreateSprite()
EntityTexture trees,arb
ScaleSprite trees,32,32
EntityAlpha trees,1
EntityType trees,type_ground
PositionEntity trees,40,15,-460
EntityParent trees,pinetrunk

The combined "tree" will not center with the sprite.
I've worked on this for hours off and on.Tried everything.
The scale,the order of entry,using move rather than position and nothing worked.Then BINGO.

The messup came from EntityType pinetree,type_ground.
Changing the type makes no difference,the same command in the other two cases works ok,the parent part of the deal makes no difference.

So what the heck is this all about. Is there a bug I don't know about?

Be interested in any thoughts.


wizzlefish(Posted 2005) [#2]
First of all, sprites cannot be assigned collision types, as may be the problem with:
EntityType trees,type_ground



Ross C(Posted 2005) [#3]
Sprites can be assigned collision types. They just can't use the polygon method of collision detection.


Ross C(Posted 2005) [#4]
Remember also and position your entities, then give them the collision types, or they might get stuck when being moved.


Jack(Posted 2005) [#5]
Thankls for the replies guys.

Here is what I found after a few more hours.

I got the positioning right with the things I did above but I was not then able to get any collision detection from the primitives.I changed all kind of things.Type_name and type numbers and well as collision detection 1,2,3.

Zilch - I couldn't have both until ---- I removed the entity_type command for the sprite. Now everything is fine. I also tried a different type for the sprite but that also fouled things up.

So - where does that leave things. Ross C are you sure about sprites taking an entity assignment? At least in this case it did not fly for me. But there may be something else I could change to make it work.

Either way - as I believe I have seen posted elsewhere - the sprite-entity combination needs work. I don't know if this is a missing feature or a bug but the whole thing needs attention.


RiverRatt(Posted 2005) [#6]
I think you just need to give the sprites an entity box and or an entity radius,and you can use collision detection method 2 or 3.


DJWoodgate(Posted 2005) [#7]
I do not see you setting a radius for your sprite entities. Sprites should behave in the same way as entities as far as type assignment goes. They will take it alright. However a sprite is not a conventional mesh so forget relying on poly picks\collisions. The best you can do is to set a radius (or try setting a box, though this will not follow sprite orientation).

Maybe the simplest option is to just define a box or an elipsoid that contains the main trunk of the tree sprite and some of the foilage as RiverRatt just said.


Jack(Posted 2005) [#8]
Well DJ I didn't use a bounding box or sphere because I want more accurate collision detection.

As you can see by my example I AM defining a separate trunk and top.And in some cases 2 tops (cones,boxes,cylinders) whatever gives the best collision detection.This should provide more accurate detection.

However - none of this explains why using "EntityType trees,type_ground" command causes repositioning.Sometimes major movement in all sprites in the scene.


Ross C(Posted 2005) [#9]
Well, if you assign an entitytype to an entity, then move something, it might get stuck on that entity. Position all your entities first, then assign entitytypes.

You can't use anything other than box and elipise for sprites. Poly doesn't work with them.