Jump to content

Adding physicsImposter does odd behavior


Pryme8
 Share

Recommended Posts

So I have a scene where I am building the colliers for the scene after the visual meshes are constructed.  I have been trying to get this code to work:
 

if(this.assets['Ground-Body-0'].physicsImposter){
				this.assets['Ground-Body-0'].physicsImposter.dispose()
			}
			this.assets['Ground-Body-0'].scaling.z = (Math.ceil(level/5)+1)*this.scale*12
			this.assets['Ground-Body-0'].position.z = Math.ceil(level/5)*12			
			this.assets['Ground-Body-0'].renderingGroupId = 2
			
			var wallColliders = []
		
			wallColliders.push(this.assets['Ground-Body-0'].clone('Wall-Body-0'))
			wallColliders[0].position.x =  -this.scale*6
			wallColliders[0].setPivotPoint(new BABYLON.Vector3(this.scale*3, 0, 0))			
			wallColliders[0].rotation.z =  -Math.PI*0.2
			
			wallColliders.push(this.assets['Ground-Body-0'].clone('Wall-Body-1'))
			wallColliders[1].position.x =  this.scale*6
			wallColliders[1].setPivotPoint(new BABYLON.Vector3(-this.scale*3, 0, 0))			
			wallColliders[1].rotation.z =  Math.PI*0.2
			
			this.assets['Ground-Body-0'].physicsImposter =  
			new BABYLON.PhysicsImpostor(this.assets['Ground-Body-0'], BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, restitution: 0.3 },  this.scene)
			
			//wallColliders[0].physicsImposter =  
			//new BABYLON.PhysicsImpostor(wallColliders[0], BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, restitution: 0.3 },  this.scene)
			
			//wallColliders[1].physicsImposter =  
			//new BABYLON.PhysicsImpostor(wallColliders[1], BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, restitution: 0.3 },  this.scene)

What I am noticing, is when I add the physics imposter to the "wall" it disappears.  Alternatively if I create the imposter first and then clone the "ground" mesh, I get the same results of the walls disappearing.   

Ive tried making it unique geometry, backing the transform etc... and am kinda stumped.

Pretty sure its linked to the set PivotPoint, but I was just wondering if anyone had any input on to what would cause behavior like this.

Link to comment
Share on other sites

  • 2 weeks later...

When you miscalculated a position or any of the joint's values (or, well, whenever I make a mistake developing the physcis plugins), there is a chance the physics engine will react rather aggressively and will throw the body "somewhere" in a single frame. 

If you can reproduce this in the plyground I will be able to help with finding what went wrong

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...