YouGroove Posted February 24, 2014 Share Posted February 24, 2014 Ok, so you need the collision part. Ok i will post the collision code also. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted February 24, 2014 Share Posted February 24, 2014 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. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
X54321 Posted February 24, 2014 Author Share Posted February 24, 2014 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. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 24, 2014 Share Posted February 24, 2014 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) Quote Stop toying and make games Link to comment Share on other sites More sharing options...
X54321 Posted February 25, 2014 Author Share Posted February 25, 2014 I'll be posting it to the Bug Reports in a moment. 1 Quote Link to comment Share on other sites More sharing options...
X54321 Posted March 2, 2014 Author Share Posted March 2, 2014 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. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 2, 2014 Share Posted March 2, 2014 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) 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.