- Home /
Using Raycasts
I'm using a linecast between the player and gameobjects on the ground. I am able to change the transform.position when the condition is met. However, it will not stay in that position and falls to the ground.
public Transform playerReachStart; public Transform playerReachEnd; public LayerMask brick; public GameObject Target; public bool inRange; void Update(){ Raycasting(); Behaviours(); }
void Raycasting(){ inRange = Physics2D.Linecast(playerReachStart.position, playerReachEnd.position, 1<< LayerMask.NameToLayer("Brick")); } void Behaviours(){ Target.transform.position = playerReachStart.postion;
Your answer
Follow this Question
Related Questions
C# Raycast Code not working 2 Answers
Unity - Remove GameObject 0 Answers
Selecting and deselecting gameobject to change material 0 Answers
Oculus Raycast different in Build (compared to Play Mode) 0 Answers