Unity3d enemy cone angle implementation idea, unity3d cone

Source: Internet
Author: User

Unity3d enemy cone angle implementation idea, unity3d cone

In particular, we want to achieve a conical angle effect like the death of an army.



Think about it. Think of some stupid methods. If you have any good methods, please let me know.

1. Raycast Method


Transmits rays from the position of a person, and thenDebug. DrawLine

However, only rays can be drawn without cone effects.

        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 must be implemented in the OnDrawGizmos () event

2. Spotlight Method




The simplest method is to place the Spotlight on the horizontal plane and over the ground. If you want to project something like the ground, create a new layer and set it to Spotlight culling mask to enable it to avoid unnecessary illumination.



3. Projection Method

The most cheating method is to put a conical object above the character, where the blogger is lazy, uses plane, places it in a place not visible to the camera (infinitely higher), and adds a new direction of light, in the vertical direction, the layer settings are the same as above. To change the shadow color, write the shader by yourself ..



You can tell me a better way.


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

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.