Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by John-Gray · Jan 31, 2013 at 11:48 AM · animationerrorlightcurve

Animating Light Intensity with Animation Curve

Hi guys.

I am currently working on a small script to animate lights with a curve defined in a custom editor. I have checked that the curve being passed at runtime matches the curve defined in the editor and it does, however when I try to assign the curve to an animation clip I am recieving an error I cannot seem to resolve.

The error is:

Can't assign curve because the type does not inherit from Component. UnityEngine.AnimationClip:SetCurve(String, Type, String, AnimationCurve) LightingTrigger:Start() (at Assets/AbeHD Assets/Scripts/Lighting/LightingTrigger.cs:33)

and the code for my setup is:

 using UnityEngine;
 using System;
 using System.Collections;
 
 [Serializable]
 
 [RequireComponent(typeof(BoxCollider))]
 [RequireComponent(typeof(Animation))]
 
 public class LightingTrigger : MonoBehaviour {
 
     private BoxCollider m_cBoxCollider;
     private Light m_cLight;
 
     private Animation m_cAnimation;
     private AnimationClip m_cIntensityClip;
     public AnimationCurve m_cIntensityCurve;
 
     private float m_fIntensity;
 
     // Use this for initialization
     void Start () {
 
         m_cBoxCollider = GetComponent<BoxCollider>();
         m_cBoxCollider.isTrigger = true;
 
         m_cLight = GetComponent<Light>();
 
         m_cAnimation = GetComponent<Animation>();
 
         m_cIntensityClip = new AnimationClip();
 
         m_cIntensityClip.SetCurve("", typeof(float), "light.intensity", m_cIntensityCurve);
 
         m_cAnimation.AddClip(m_cIntensityClip, "Intensity");
         m_cAnimation.Play("Intensity");
     }
 }

Any advice on what I am doing incorrectly would be very much appreciated!

Thanks.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Berenger · Jan 31, 2013 at 01:06 PM

I've never used it but, apparently, for the second parameter, you need the type of component that has a variable the name of the string in the third parameter. Try ...

 m_cIntensityClip.SetCurve("", typeof(Light), "intensity", m_cIntensityCurve);
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animate mode does not contain definition for GetCurveBindings 2 Answers

Animation error message, can anyone explain? 1 Answer

The AnimationClip 'Running' used by the AnimationComponent 'corpse' must be marked as Legacy? 1 Answer

Mecanim errors after animation clip import 1 Answer

Only torso of sprite has weights 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges