Jump to content

PhysicSetPosition crashing


YouGroove
 Share

Recommended Posts

I have some ball projectile that works great using SetPosition(x,y,z)

But when i replace that with PhysicsSetPosition() it crashes ?

 

Here is the main loop code :

 

 


function Script:updatebullet()

       self.bullIncr = self.bullIncr + 0.05

       if self.bullActive == true then
       -- Offset towards direction to not collision with player
       pos = self.bullStartPoint + (self.bulldirN * 2 *  self.bullIncr)

       -- more above ground
       pos.y = 1.5 

       --self.bullet:SetPosition(pos.x,pos.y,pos.z )
       self.bullet:PhysicsSetPosition(pos.x,pos.y,pos.z , 1)
...

 

I used at start creation of the ball SetCollisionType for it to work with PhysicsSetPosition()


   self.bullet =  Model:Sphere()
    self.bullet:SetColor(1,1,1)
    self.bullet:SetMass(0)
    self.bullet:Show()
   self.bullet:SetCollisionType(Collision.Prop)   

 

What could be the problem ?

Stop toying and make games

Link to comment
Share on other sites

In lua it says error in function if i use Vec3 ?

-------------

Another question , at init, i just want to place the physic ball at a position , do i need to use PhysicSetPosition ?

or just SetPosition ?

and call PhysicsSetPosition only when moving the ball at updates ?

Stop toying and make games

Link to comment
Share on other sites

Well using Vec3, the debugger says error in Function.

Using 4 parameters no roblem but it crashes.

I tried also 0,0,0 as position where there is no geometry but it crashes ?

 

Could it be mass = 0 the problem ? or physics= debris ?

 

Does anyone uses PhysiscSetPosition without problem ? (i remember some elevator example on workshop using that, i'll take a look)

Stop toying and make games

Link to comment
Share on other sites

Ok found the problem :

You must use a mass different from 0

 

Also if you want it to Physic collide and not path trhought physic object you have to simply also give it a shape as it's created by code :

 

self.bullet = Model:Sphere()
 self.bullet:SetColor(1,1,1)
 self.bullet:SetMass(0.02)
self.bullet:SetGravityMode(false)
self.bullet:Show()
self.bullet:SetCollisionType(Collision.Prop)

 --Create a shape
 local shape = Shape:Sphere(0,0,0, 0,0,0, 1,1,1)
 self.bullet:SetShape(shape)
 shape:Release()

 

 

 

ok i have bullet a stand alone prefab with it's own script and it works better.

Stop toying and make games

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.

 Share

×
×
  • Create New...