Hi, i’m trying to get it so the raycast i’m shooting when i press fire1 alternates between a random range (i.e. instead of the ray shooting in the perfect forward direction - its inaccurate and creates recoil). This is my raycast script with randX, randY, and randZ. And i’m trying to do this:
var randX = Random.Range(0.1,-0.1);
var randY = Random.Range(0.1,-0.1);
var randZ = Random.Range(0.1,-0.1);
"One of the lines of Raycast code" += Vector3 (randX,randY,randZ);
Is this correct - does anyone know how i can incorporate that last line into this raycast code:
var Hit : RaycastHit;
var DirectionRay = transform.forward;
var randX = Random.Range(0.1,-0.1);
var randY = Random.Range(0.1,-0.1);
var randZ = Random.Range(0.1,-0.1);
Debug.DrawRay(transform.position , DirectionRay * Range , Color.blue);
if(Physics.Raycast(transform.position , DirectionRay , Hit , Range)){
var particleClone = Instantiate(Effect, Hit.point, Quaternion.LookRotation(Hit.normal));
Destroy(particleClone.gameObject, 2);
If i’m completley wrong can someone show me how its done with that code ^ ^.
Thanks
-Fin