简体   繁体   中英

Unity3d Physics.Raycast not working ('Physics' does not contain a defenition for 'Raycast')

So this is my code;

void Update()
{
    RaycastHit hit;
    if(Physics.Raycast(transform.position, Vector3.down, 100, out hit))
    {
        //Do something
    }
}

And it is not working. When I do this it will say;

'Physics' does not contain a defenition for 'Raycast'

This script is in a completeley new project in a completeley new script.

Does anybody know the reason behind this?

I think the constructor is wrong. Try swap "100" and "out hit"

if(Physics.Raycast(transform.position, Vector3.down, out hit, 100))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM