Utilisation layer-mask (Optionnel) pour les interactions

This commit is contained in:
Antoine H 2020-12-03 15:41:30 +01:00
parent 4db5201ecb
commit 594de91135
3 changed files with 6 additions and 6 deletions

View file

@ -136,7 +136,7 @@ GameObject:
- component: {fileID: 107140167}
- component: {fileID: 107140166}
- component: {fileID: 107140169}
m_Layer: 0
m_Layer: 8
m_Name: Oldman
m_TagString: Client
m_Icon: {fileID: 0}
@ -348,7 +348,7 @@ GameObject:
- component: {fileID: 698542427}
- component: {fileID: 698542426}
- component: {fileID: 698542425}
m_Layer: 0
m_Layer: 8
m_Name: Chicken
m_TagString: Grabable
m_Icon: {fileID: 0}

View file

@ -81,8 +81,8 @@ public class Tavernkeeper_controller : MonoBehaviour
void handAction(string hand)
{
// Test collision of ray from tavernkeeper center (A verifier) at action_dist unit distance
RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.2f, lookDirection, action_dist);
// Test collision of ray from tavernkeeper center (A verifier) at action_dist unit distance on Interactions layer
RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.2f, lookDirection, action_dist, LayerMask.GetMask("Interactions"));
if (hit.collider != null)
{
GameObject hit_object = hit.collider.gameObject;
@ -92,7 +92,7 @@ public class Tavernkeeper_controller : MonoBehaviour
//Empty hand : try grab grabable object
if(hand_container[hand] is null)
{
if(hit_object.tag == "Grabable") //by tag or with parent-name ?
if(hit_object.tag == "Grabable") //by tag, layer-mask or with parent-name ?
{
// hit_object.transform.SetParent(transform);
// hit_object.transform.localPosition = new Vector2(-0.2f,0.2f);

View file

@ -15,7 +15,7 @@ TagManager:
- UI
-
-
-
- Interactions
-
-
-