I need help with testing if my line renderer can collide. It is rapidly growing and it is supposed to stop whenever it hits an obstacle, which could be anywhere on the map. I don’t have any currently don’t have any code for this, so if you could write some it would help.
I have tried so much, done a lot of research, and I’m not super advanced so any help would be appreciated.
1 Answer
1
I can’t seem to get the positions of the LineRenderer, so you’ll have to put them into this list before applying them to the LineRenderer. I guess you can do this since you said it was gonna grow rapidly.
private List<Vector3> positions;
[SerializeField]
private LayerMask collisionMask;
private void FixedUpdate()
{
for (int i = 0; i < this.positions.Count - 1; i++)
{
RaycastHit hit;
if (Physics.Linecast(this.positions*, this.positions[i + 1], out hit, this.collisionMask))*
{
this.OnRayCollision(hit);
}
}
}
private void OnRayCollision(RaycastHit hit)
{
Debug.Log(“Ray hit”);
}
startTime = Time.time; dificultyMultiplier = 1 + (time.Time-startTime)/dificultyConstant; DifficultyConstant is the time required to initially double the difficulty. It progresses at a linear rate, and if you want non linear than I'd recommend dividing by an exponential.
– oStaiko