Jump to content
X54321

[Leadwerks 3 Indie Edition] Projectile collision

Recommended Posts

Add this to your player script :

 

function Script:hitPlayer(healthDown)
       self.health = self.health - healthDown
end

 

And change this to your missile script :

 

function Script:Collision(entity, position, normal, speed)



   local typeEnt = entity:GetKeyValue("type", "")
   if typeEnt == "player" then

       entity.script:hitPlayer(5)

   end

   self:stopbullet()
end

 

Collision will work this way.

Share this post


Link to post

I still don't think you understand the problem. The missile DOES collide with the player, and it DOES hurt the player, but only when the player is moving during the collision.

Share this post


Link to post

I seen that.

In fact there is some bug with character physics as collision seems to occur only in your arm player model attached to the static character.

 

I would recommend that you do like FPS tutorial :

Have the static character import by code in it's script the animated arm and weapon as a prefab.

Than the prefab weapon script will play animations and manage all weapon related stuff.

(Yes must be a bug as character controller should collide with missile)

 

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

 

Even with Camera as external not as child, and i tried some other stuff it failed.

I really don't understand why collision don't work as all is fine, it seems that collision go hazardous.

 

You should post your project in Bug Reports and ask why collision don't work well.

(even with correct code it should work fine)

Share this post


Link to post

Well, I found a way around this. I'm surprised I haven't thought of this before, but instead of testing for collisions I can just test if the player's distance to the missile is less than X amount of units. This effectively makes a sphere collision that works well.

Share this post


Link to post

Sphere collision can be great.

But beware, you must keep physic collision for the missile for the environment, so this is more code you make because if you keep physic collision, it will always be enabled and should work with player without having to code some workaround.

 

That's very stange , as i use Physic collision for my game and it just works great without any bug, perhaps you have some specific problem with your models ? (would like to see something from your bug report)

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...