Hello guys !
I have the following code, which generetes a Vector and reflects a new one.
if (Physics.Raycast(rayEmitter.position, FirstRay * distance, out hit0, Mathf.Infinity, PrefabMask))
{
if (hit0.collider.gameObject.tag == "mirror")
{
Vector3 incidenceAngle0 = hit0.point - rayEmitter.position;
Vector3 reflectionAngle0 = Vector3.Reflect(incidenceAngle0, hit0.normal);
target0 = hit0.transform;
Debug.DrawRay(hit0.point, reflectionAngle0*distance, Color.white);
// timer += Time.deltaTime;
// if (timer >= timeStep)
// {
timer = 0F;
[COLOR="blue"] Quaternion rot2 = Quaternion.identity;
Rigidbody beamHeader2 = GameObject.Instantiate(beamHeader, hit0.point, rot2) as Rigidbody;
beamHeader2.AddForce(reflectionAngle0 *rayDistance);
beamHeader2.detectCollisions = false;[/COLOR]
// }
if (Physics.Raycast(target0.position, reflectionAngle0 * distance, out hit1, Mathf.Infinity, PrefabMask))
{
if (hit1.collider.gameObject.tag == "mirror")
{
Vector3 incidenceAngle1 = hit1.point - target0.position;
Vector3 reflectionAngle1 = Vector3.Reflect(incidenceAngle1, hit1.normal);
target1 = hit1.transform;
.....
I’m trying to instantiate a prefab w/ a rigidbody and a trail render to make the beam “trail”. When the rayDistance var is 1, this happens:
So, as you see, because the force is very weak, the projectile isn’t launched properly, thus not leaving the beam trail.
Now, when I change the rayDistance var to lets say, 300, this is what happens:
Despite launching the projectile with proper force now, the projectile isn’t created where it should be. Is there a way to fix this?
Thanks in advance !

