Unity3d the idea of the enemy cone angle of view

Source: Internet
Author: User

In particular, the cone-shaped angle effect like the Allied Suicide Squad.



Think about it, think of a few stupid ways, if you have a good way, please tell me

1.Raycast method


Transmitting rays forward from the character position, then debug.drawline

But only the rays are drawn, without the cone effect.

        if (Physics.raycast (Transform.position, raydirection, out hit, viewdistance))        {            //check the aspect            if ( Hit.collider.name! = "Player")            {                debug.drawline (transform.position, Hit.point, Color.green);}        }        else        {            debug.drawline (transform.position, Leftraypoint, Color.green);         }

Debug.drawline to be implemented in the Ondrawgizmos () event

2.Spotlight method




The simplest way, the spotlight spotlight is placed horizontally, above the ground, and what you want to project, like the ground, opens in a new layer set to spotlight culling mask to avoid unnecessary illumination.



3. Projection method

The most cheating method, put a conical object above the character, Bo Master in this lazy, with the plane, placed in the camera can not see the place (infinitely high), in a new direction of light, vertical direction, layer settings ibid, want to change the shadow color can write their own shader.



You guys have a better way to tell me.


-----by wolf96 http://blog.csdn.net/wolf96

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Unity3d the idea of the enemy cone angle of view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.