December 04, 2020, 10:38:12 AM

Author Topic: [bb] No Reponse Collisions by Ken Lynch [ 1+ years ago ]  (Read 683 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] No Reponse Collisions by Ken Lynch [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : No Reponse Collisions
Author : Ken Lynch
Posted : 1+ years ago

Description : This is a small example of how I've used the existing collision system to force a 'no response'. I've used a pivot to parent the object and use the pivot collisions when I want sliding/stop collisions and the actual object if I want to go through the object.

This is useful for collectable items that you don't want to affect your movement.


Code :
Code: BlitzBasic
  1. Graphics3D 800,600
  2.  
  3. light% = CreateLight()
  4. camera% = CreateCamera()
  5.  
  6. pivot% = CreatePivot()
  7. EntityType pivot, 1
  8. EntityRadius pivot, 0.1
  9.  
  10. sphere% = CreateSphere()
  11. ScaleEntity sphere, 0.1, 0.1, 0.1
  12. EntityRadius sphere, 0.1
  13. EntityType sphere, 2
  14. EntityParent sphere, pivot
  15.  
  16. PositionEntity camera, 0, 2, -2
  17. PointEntity camera, pivot
  18.  
  19. For i = 0 To 5
  20.  
  21.         cube = CreateCube()
  22.         EntityType cube, 3
  23.         PositionEntity cube, Rnd(-2, 2), 0, Rnd(-2, 2)
  24.         ScaleEntity cube, 0.2, 0.2, 0.2
  25.        
  26. Next
  27.  
  28. For i = 0 To 5
  29.  
  30.         ball = CreateCylinder()
  31.         EntityType ball, 4
  32.         PositionEntity ball, Rnd(-2, 2), 0, Rnd(-2, 2)
  33.         ScaleEntity ball, 0.2, 0.2, 0.2
  34.        
  35. Next
  36.  
  37. Collisions 2, 3, 2, 2
  38. Collisions 1, 4, 2, 2
  39.  
  40. Repeat
  41.  
  42.         If KeyDown(200) Then TranslateEntity pivot, 0, 0, 0.1
  43.         If KeyDown(208) Then TranslateEntity pivot, 0, 0, -0.1
  44.         If KeyDown(203) Then TranslateEntity pivot, -0.1, 0, 0
  45.         If KeyDown(205) Then TranslateEntity pivot, 0.1, 0, 0
  46.  
  47.         UpdateWorld
  48.  
  49.         PositionEntity sphere, 0, 0, 0
  50.        
  51.         cyl_col% = cyl_col + CountCollisions(pivot)
  52.         cube_col% = cube_col + CountCollisions(sphere)
  53.  
  54.         ResetEntity sphere
  55.  
  56.         RenderWorld
  57.  
  58.         Text 0, 0, "Cylinder Collisions: " + cyl_col   
  59.         Text 0, 16, "Cube Collisions: " + cube_col
  60.        
  61.         Flip
  62.  
  63. Until KeyHit(1)


Comments :


_PJ_(Posted 1+ years ago)

 Won't the pivots eventually be offset from the meshes after numerous collisons, though?Nevermind... I saw this:
Code: [Select]
PositionEntity sphere,0,0,0
Still, if a collision causes a stop or slide, the pivot will be affected, then the mesh would be moved, in effect, the same as if the collision was checked on the mesh? [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal