Jump to content

Collision problem


YouGroove
 Share

Recommended Posts

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

Stop toying and make games

Link to comment
Share on other sites

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.

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...