YouGroove Posted February 16, 2014 Share Posted February 16, 2014 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 ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted February 16, 2014 Share Posted February 16, 2014 Try making it a Vec3() object you pass instead of x, y, z self.bullet:PhysicsSetPosition(Vec3(pos.x, pos.y, pos.z), 1) I think I remember someone saying the doc was wrong or something. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 16, 2014 Author Share Posted February 16, 2014 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 ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted February 16, 2014 Share Posted February 16, 2014 You can just use SetPosition() at start. SetPosition() breaks physics for that frame but since it's at start it doesn't matter. Are you sure pos is a vec3 when it returns from your calculation? Did you put a breakpoint in and see what it contains? Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 16, 2014 Author Share Posted February 16, 2014 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) Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted February 16, 2014 Author Share Posted February 16, 2014 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. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Recommended Posts
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.