YouGroove Posted August 11, 2015 Share Posted August 11, 2015 I have a player and some ennemy entitie, to have raycast from both working able to detect each other i must only hide one entity like the player before calling Raycast. This code below have the player unable to detect the ennemy using raycast , while the ennemy detect the player. Ennemy function Script:RaycastPlayer() self.entity:SetPickMode(0) self.hitbox:SetPickMode(0) ... self.entity:SetPickMode(1) self.hitbox:SetPickMode(1) end Player function Script:Raycast() self.entity:SetPickMode(0) self.hitbox:SetPickMode(0) ... self.entity:SetPickMode(1) self.hitbox:SetPickMode(1) end So the solution was to start the raycast begin point outside of the ennemy collision box , so i don't need to call Hide Ennemy function Script:RaycastPlayer() -- self.entity:SetPickMode(0) -- self.hitbox:SetPickMode(0) ... -- self.entity:SetPickMode(1) -- self.hitbox:SetPickMode(1) end With only the player calling Hide() i have the player and ennemy able to detect each other using Raycast. The question : Are the scripts called simultaneously ? because it seems calling Hide() on the ennemy occurs when the player have also called Hide() already. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted August 11, 2015 Share Posted August 11, 2015 I don't think you should rely on attached script call order. When world:Update() is ran all attached scripts get ran as well. Most likely they are ran in the order the entity was created but relying on that isn't ideal. Are you showing after you are done hiding? In your script you should call hide(), raycast, show() Quote Link to comment Share on other sites More sharing options...
YouGroove Posted August 11, 2015 Author Share Posted August 11, 2015 Yes, it works using Show() and Hide() on both player and ennemy. I expected SetPickMode() to work and find that strange behaviour if you change PickMode() on both characters when they do a RayCast. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted August 11, 2015 Share Posted August 11, 2015 I think it's supposed to and you may not be using it right. I generally just show/hide because it's easy enough. I'm sure mac could come along and set us straight as he knows all this stuff. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted August 11, 2015 Author Share Posted August 11, 2015 I think it's supposed to and you may not be using it right. As you see the code above it's pretty simple and forward. Anyway it doesn't work this way. The other problem is Follow() with bad accelerations many times near the goal point, i'm thinking about having three raycast on the character one forward and two 45° left and right to detect and have some smooth dynamic obstacle avoidance and others ennemys avoidance. 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.