Jump to content

Hello I posted this to unity answers as well, but I thought I would try here as well. I am making a game and when I cast rays they only shoot a specific distance, not the one I told them too and I have no idea why, has anyone else had this problem?

-thanks

 

 
if (Input.GetMouseButton(0) || Input.GetKeyDown(KeyCode.E)) {
RaycastHit hit;
if(Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit, 100.0f)){
if (hit.transform.tag == "Enemy") {
hit.transform.gameObject.GetComponent<Enemyscript>().health -= 10;
}
Link to comment
https://linustechtips.com/topic/186189-unity-raycasting-problem/
Share on other sites

Link to post
Share on other sites

http://docs.unity3d.com/ScriptReference/Physics.Raycast.html

 

 

The 4th argument is for the distance the ray should be cast. Looks like you can leave off that argument and it will default to Mathf.Infinity

main(i){for(;i<101;i++)printf("Fizz\n\0Fizzz\bBuzz\n\0%d\n"+(!(i%5)^!!(i%3)*3)*6,i);}

Link to comment
https://linustechtips.com/topic/186189-unity-raycasting-problem/#findComment-2504681
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×