Jump to content

Recommended Posts

Posted

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.

Stop toying and make games

Posted

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()

Posted

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.

Stop toying and make games

Posted

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.

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

Stop toying and make games

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.

×
×
  • Create New...