Hello everyone, i have a raycast problem. Here is my code :
var direction = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
if (Physics.Raycast(transform.position, direction, hit)){
if (hitParticles) {
hitParticles.transform.position = hit.point;
hitParticles.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
hitParticles.Emit();
}
}
Now my problem, this code is attached to the empty game object which stands in front of the scope, but when i fire it without moving the mouse, the particle is being emitted in two positions. For example, i’m firing it to the wall, there is y:30 point in the wall and y:25 point below it. Some of the fires goes to y:30 , some of it goes to y:25, which means my fire is not stable ,and also sometimes the particle is not even emitted, which means we don’t hit anything, what can be the problem ?
Thanks :).
I tried what you said, and there were 2 red lines, one was static and from the point which is right, and the other one was from somewhere below and rotating till somewhere, then going to the same position it started ( it is somewhere below the gun ) and rotates again, any ideas ? ( and thanks)
– Inan-Evin