Question by
Robertgold · Jul 31, 2017 at 08:23 PM ·
physicsraycastbouncing
[UNSOLVED] Bouncing ray cast
Am trying to create a system that allows a bullet to bounce of walls in an expected way as seen in this picture:
Currently when I am running my game I get a reflection which can be seen here: This is obviously what wasn't intended and I'm not sure why my code doesn't work as intended.
The code for the reflection can be seen here (using c#)...
if (Physics.Raycast(this.transform.position, Vector3.forward, out hitInfo, 100f))
{
Vector3 incomingV = hitInfo.normal - transform.position;
Vector3 reflectV = Vector3.Reflect(incomingV, hitInfo.normal);
laserLine.SetPosition(2, reflectV);
Any help or suggestions are welcome.
unityv2.png
(415.3 kB)
Comment
Should inco$$anonymous$$gV not be: hitinfo*.point* - transform.position?