Helllo, I have another problem that I have stumbled onto yet again!
So today I decided to make a new bullet penetration system based on the width of the object it is going to penetrate, It was going to acchieve this by having a transform infront of the bullet that was constantly doing a backwards RayCast and then it stores the hit position of the raycast. And on the actual bullet there is a script that takes the transform at the point of impact and compares the distance between the two points and prints it in the debug. However I programmed all of this and I am encountering some wierd problems, when I shoot at a wall the debug log is saying that thin walls are thicker than the thick walls. This is probably a verry stupid mistake on my behalf, but I just wondered if anyone could help me.
Here are the snippets from my code:
#pragma strict
var hit : RaycastHit;
public var hitposition : Vector3;
function Start () {
}
function Update () {
if (Physics.Raycast (transform.position, Vector3.back, hit, 2)) {
hitposition = hit.point;
Debug.Log("hit");
}
}
EntryPoint = hit.point;
ExitPoint = Caster.GetComponent(PenetrationCast).hitposition;
Width = Vector3.Distance(EntryPoint, ExitPoint);
Debug.Log("Width is: " + Width);
Any help would be appreciated, thanks!