Problems with Rotating
Blitz3D Forums/Blitz3D Beginners Area/Problems with Rotating
| ||
I created a badguy type, "badguytype", and I want to rotate each one every frame, or each time my "While...Wend" loop starts over. I did this:For spin.badguytype = Each badguytype RotateEntity spin\entityhandle Next Yet nothing happens. What should I do? A second problem I have is with collisions. I have a couple of meshes that I want to disappear if the camera runs into them, yet this: If EntityCollided(camera,weapon) HideEntity weapon weapon\pickedup = True EndIf This doesn't work. Did I put this code in the wrong part of my main loop? |
| ||
"RotateEntity spin\entityhandle" - does not, and it will not work. Rotateentity spin\entityhandle, Pitch, Yaw, Roll - works I ussually have something like this on the main loop: a=a+1 rotateentity MyEntity,a,a,a You should have a Field called Entity or Ent Type Weapon Field Ent end type Load the Mesh into weapon\ent then on your function: If EntityCollided(camera,weapon) HideEntity weapon\ent weapon\pickedup = True EndIf |
| ||
Maybe better use Turnentity badguy,0,1,0 to rotate it continously in small steps without an angle counter. BTW EntityCollided does need the Type of the entity, not the handle (check the description!)! The type of the entity is defined by you and is used for Collisions declaration: entitytype camera,1 entitytype weapon,2 collisions 1,2,2,2 ... Updateworld() if entitycollided(camera,2)=weapon ... endif But this is pretty slow, just to get that pickup function. Maybe you better use If entitydistance(camera, weapon)<2.0 ; whatever distance ; pick it up etc. endif ---------- After some time you'll find out that it's better to use a player pivot for the player and use it for such tasks, instead the camera. The camera will then be parented to the player pivot and only look up and down, while the player rotates left/right and moves. player=createpivot() camera=createcamera(player) translateentity camera,0,2,0 .... camxsp#=mousexspeed() camysp#=-mouseyspeed() turnentity player,0,camxsp#/4.0,0 turnentity camera,camysp#/4.0,0,0,1 .... So then you would define Entityradius, Collisions and Stuff pickups etc. for the player. |
| ||
Yes, what jfk says. |
| ||
thanks! |
| ||
ok - I got the rotating to work - but for some reason the EntityDistance thing doesn't work. Should I put it before UpdateWorld, between UpdateWorld and RenderWorld, after RenderWorld and before Flip, or after Flip? |
| ||
I'd put it after updateworld() ;navigation updateworld() if entitydistance(camera,weapon)<mindist# ;... endif renderworld() flip If it doesn't work, increase the mindist#. And if you are using EntityDistance, you won't need to set up Collision for the weapon. |
| ||
OK....thanks... |