Jump to content

[Leadwerks 3 Indie Edition] Projectile collision


X54321
 Share

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.

Stop toying and make games

Link to comment
Share on other sites

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)

Stop toying and make games

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

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