Hey guys
I have made this skidmark proc animation that uses the trailrenderer. only problem is it does not take into account where it is to to render on. Ideally I would want it to only render on the road rather than any other terrain.
Anyone got any ideas?
See the images for further details
Also here is the code as it is now
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Effects : MonoBehaviour
{
public TrailRenderer[] skidMarks;
private bool skidMarksFlag;
public Material lightSwitch;
private void Update()
{
checksteer();
}
private void checksteer()
{
if (Mathf.Abs(Input.GetAxis("Vertical")) < 0.1f)
{
lightSwitch.EnableKeyword("_EMISSION");
}
else
{
lightSwitch.DisableKeyword("_EMISSION");
}
if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.1f && Mathf.Abs(Input.GetAxis("Vertical")) > 0.1f)
{
startEmitter();
}
else
{
stopEmitter();
}
}
private void startEmitter()
{
if (skidMarksFlag) return;
foreach (TrailRenderer T in skidMarks)
{
T.emitting = true;
}
skidMarksFlag = true;
}
private void stopEmitter()
{
if (!skidMarksFlag) return;
foreach (TrailRenderer T in skidMarks)
{
T.emitting = false;
}
skidMarksFlag = false;
}
}