Sprite add shadow swing animation (9 of Unity3D development), spriteunity3d

Source: Internet
Author: User

Sprite add shadow swing animation (9 of Unity3D development), spriteunity3d

Monkey original, reprinted. Reprinted Please note:Reposted from Cocos2D Development Network-cocos2dev.com. Thank you!

Original article address:Http://www.cocos2dev.com /? P = 575


Today, I saw a very simple swing animation. It feels good. Record, which can be used later. It is mainly used to calculate the position.

DropShadowAnim. cs

Using UnityEngine; using System. collections; public class DropShadowAnim: MonoBehaviour {public float radius = 0.15f; // the radius of the shadow from the parent to public float maxAngle = 45.0f; // maximum angle of shadow swing between left and right public float period = 2.0f; // how many seconds does one swing take private Transform trans; void Start () {trans = this. transform;} void Update () {float phase = Time. realtimeSinceStartup * (2.0f * Mathf. PI)/period; float angle = Mathf. sin (phase) * (Mathf. deg2Rad * maxAngle); float startX = 0.0f; float startY =-radius; float sinAngle = Mathf. sin (angle); float cosAngle = Mathf. cos (angle); float x = cosAngle * startX-sinAngle * startY; float y = sinAngle * startX + cosAngle * startY; trans. localPosition = new Vector3 (x, y, 0.0f );}}

It is very easy to use.


1. Create a Sprite as a parent;
2. Copy the created Sprite. Drag to Step 1 as its sub-object.
3. Change the sprite Renderer Color in step 2 to black as the shadow.
4. Add an animation script to Sprite in step 2.

OK. This is done.



Does the bxf skeleton animation not contain a model? Do I need to add another model in unity3D?

Is it fbx ?! Yes. You can place the texture in the same path ~ Materials are automatically generated when used, but the number of playback frames must be set for the animation ~

Learning computer is the largest unity3d training, unity development, unity training base? Have that big name

If you have a program foundation, you might as well learn it by yourself. If you have the necessary skills, you can find a company for an internship.
 

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.