YouGroove Posted February 16, 2014 Share Posted February 16, 2014 I load a prefab in my player code and pass some variable it'a a bullet for the player to fire. So in code i have at bullet start() : function Script:Start() 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() self.bullet:SetPosition(200,2000,200) end But in fact the bullet collides with walls and aliens. But the trigger function collision seems ot never been called ? Why ? bad collision type at init ? Here is the simple collision code (the stopbullet() function is never called ? function Script:Collision(entity, position, normal, speed) self:stopbullet() local typeEnt = entity:GetKeyValue("type", "") if typeEnt == "alien" then --self.hearts = self.hearts -1 end end Quote Stop toying and make games Link to comment Share on other sites More sharing options...
bandrewk Posted February 16, 2014 Share Posted February 16, 2014 Try setting the swept collision mode (Entity::SetSweptCollisionMode) to true. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 16, 2014 Author Share Posted February 16, 2014 Swept collision is not the problem : The bullet is a bgi ball moving slowly and it hits level and AI , you see it collides with them. The problem is just during collision and bouncing, the collision Script seems to not be called. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted February 17, 2014 Author Share Posted February 17, 2014 My fault : I had a sphere shape and model creation by code inside a prefab that was already the physic and model sphere, it was just bad copy and paste of code that should not exit in the prefab script. So yes collision occurs very well, no problem at final. Thread can be close. 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.