Creating entities (parented), but different scales
Blitz3D Forums/Blitz3D Beginners Area/Creating entities (parented), but different scales
| ||
Dear all, Just testing out collisions, stairs etc, and am using the 1unit=1metre scale. I have created my player(cube) and scaled it to .5,2,.5 to get an ever so slightly humanoid ratio. I have also placed a blue step slightly down on the Y scale for my player to step/slide over. As I understand it, if the centre of my player is higher than the centre of any obstacle, it will slide over it. That's fine. However, I think I am using a sphere>poly collision, and this doesn't work too well in my example below. The collision sphere is much fatter and shorter than my player. To this end, I wanted to 'see' the collision sphere, so I tried to attach a sphere to my player and scale it to 1,1,1 which, I hope, would give me an indication of where the collisions are taking place. However, as you can see, I can't scale the sphere once I have parented it to my player. So, two questions: 1) How do I set a different scale for an object that is parented to another (if even possible)? 2) Is sphere>poly the best collision method when using shapes like these; it seems dodgy to me. Graphics3D 800,600,32,2 SetBuffer BackBuffer() type_player=1 type_obstacle=2 cam=CreateCamera() PositionEntity cam,0,2,-5 light=CreateLight() player=CreateCube() ScaleEntity player,.5,2,.5 EntityType player,type_player EntityAlpha player,.5 temp=CreateSphere(32,player) ScaleEntity temp,1,1,1 obstacle=CreateCube() ScaleEntity obstacle,.5,.2,.5 EntityColor obstacle,50,50,255 PositionEntity obstacle,5,-.3,5 EntityType obstacle,type_obstacle Collisions type_player,type_obstacle,2,2 ;flip While Not KeyDown(1) If KeyDown(205) TurnEntity player,0,-1,0 If KeyDown(203) TurnEntity player,0,1,0 If KeyDown(208) MoveEntity player,0,0,-.1 If KeyDown(200) MoveEntity player,0,0,.1 UpdateWorld RenderWorld Flip Wend End |
| ||
1. Use the global paramater for scaling. It is local by default. 2. You aren't setting a radius for the players collision. This defaults to 1 so will not be very accurate given that your player is taller than 1 unit. See EntityRadius which also has a second param for ellipsoid collisions. |
| ||
Can you explain your answer a little further please. I'm a bit simple. |
| ||
Look at the manual ... ScaleEntity entity,x_scale#,y_scale#,z_scalel#,[,global] Parameters: entity - name of the entity to be scaled x_scale# - x size of entity y_scale# - y size of entity z_scale# - z size of entity global (optional) - Description: Scales an entity so that it is of an absolute size. Scale values of 1,1,1 are the default size when creating/loading entities. Scale values of 2,2,2 will double the size of an entity. Scale values of 0,0,0 will make an entity disappear. Scale values of less than 0,0,0 will invert an entity and make it bigger. Note the 'global' optional parameter. EntityRadius entity,x_radius#[,y_radius#] Parameters: entity - entity handle x_radius# - x radius of entity's collision ellipsoid y_radius# (optional) - y radius of entity's collision ellipsoid. If omitted the x_radius# will be used for the y_radius#. Description: Sets the radius of an entity's collision ellipsoid. An entity radius should be set for all entities involved in ellipsoidal collisions, which is all source entities (as collisions are always ellipsoid-to-something), and whatever destination entities are involved in ellipsoid-to-ellipsoid collisions (collision method No.1). |
| ||
Thank you. |