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 Alanj2007 · Dec 15, 2013 at 05:57 AM · errorplay#pragma strictbobbing

Script Errors

Use Unity Pro 4.3.0f4

Script #1

 renderer.material.mainTexture.Play();

Error #1

Assets/PlayVideo.js(1,31): BCE0019: 'Play' is not a member of 'UnityEngine.Texture'.

Script #2

 private var timer = 0.0; 
     var bobbingSpeed = 0.18; 
     var bobbingAmount = 0.2; 
     var midpoint = 2.0; 
      
     function Update () { 
        waveslice = 0.0; 
        horizontal = Input.GetAxis("Horizontal"); 
        vertical = Input.GetAxis("Vertical"); 
        if (Mathf.Abs(horizontal) == 0 && Mathf.Abs(vertical) == 0) { 
           timer = 0.0; 
        } 
        else { 
           waveslice = Mathf.Sin(timer); 
           timer = timer + bobbingSpeed; 
           if (timer > Mathf.PI * 2) { 
              timer = timer - (Mathf.PI * 2); 
           } 
        } 
        if (waveslice != 0) { 
           translateChange = waveslice * bobbingAmount; 
           totalAxes = Mathf.Abs(horizontal) + Mathf.Abs(vertical); 
           totalAxes = Mathf.Clamp (totalAxes, 0.0, 1.0); 
           translateChange = totalAxes * translateChange; 
           transform.localPosition.y = midpoint + translateChange; 
        } 
        else { 
           transform.localPosition.y = midpoint; 
        } 
     }

SO MANY ERRORS

ERRORS

Comment
Add comment · Show 7
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
avatar image Kiloblargh · Dec 15, 2013 at 06:47 AM 0
Share

Who told you you could "Play" a Texture?

avatar image Alanj2007 · Dec 15, 2013 at 06:48 AM 0
Share

I tried it on old version and it's working .. You have any idea what's the correct then for this version?

avatar image Kiloblargh · Dec 15, 2013 at 06:56 AM 1
Share

Oh, it's a movie texture. I don't have Pro so I haven't had the chance to use those. You can play a $$anonymous$$ovieTexture but not a Texture. It may be that renderer.material.mainTexture returns type Texture even if it is a $$anonymous$$ovieTexture. So, I think you first have to have a variable of type $$anonymous$$ovieTexture, then you have to assign that $$anonymous$$ovieTexture to the renderer.material, then you can tell your $$anonymous$$ovieTexture variable to Play() directly.

avatar image Tomer-Barkan · Dec 15, 2013 at 07:02 AM 0
Share

If you want help you should explain what you're trying to do... As the error states, a Texture2D doesn't have a Play() method, so whatever you're trying to do in that first command, you're doing it wrong.

And the second script, you're trying to set many variables but you haven't defined any of them. Try adding var before each variable the first time that you use it.

And I do recommend starting with some Javascript tutorials since this is pretty basic stuff. W3Schools has a good one: http://www.w3schools.com/js/

avatar image Alanj2007 · Dec 15, 2013 at 07:04 AM 0
Share

You guys said add "var" before variable but there is

private var timer = 0.0;

var bobbingSpeed = 0.18;

var bobbingAmount = 0.2;

var midpoint = 2.0;

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Kiloblargh · Dec 15, 2013 at 06:51 AM

"Unknown Identifier" means you use a variable name that you have not declared. In Javascript / Unityscript, you must add the "`var`" keyword to declare a variable before you can assign a value to it. But don't do that in Update(). Declare them before the function in which you use them or at the top of your script.

Textures cannot be played. "Is not a member of" basically means you are trying to tell an object to do something that isn't something that kind of object does.

Comment
Add comment · Show 5 · 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
avatar image Alanj2007 · Dec 15, 2013 at 06:54 AM 0
Share

Thanks for the comment but do you know the correct script to play video?

avatar image Kiloblargh · Dec 15, 2013 at 06:58 AM 0
Share

Possibly, see comment above.

avatar image Alanj2007 · Dec 15, 2013 at 07:00 AM 0
Share

I will try. Thanks!

avatar image Alanj2007 · Dec 15, 2013 at 08:27 AM 0
Share

Idk why but Unity is actually dicking with me ...

http://docs.unity3d.com/Documentation/$$anonymous$$anual/VideoFiles.html

Exact same script I use in my game .. It's working on previous version but not in this version =='

avatar image Kiloblargh · Dec 15, 2013 at 09:09 AM 1
Share

Also from the docs: Note: If you have #pragma strict enabled in your code a $$anonymous$$ovieTexture object should be declared somewhere and the object should be initialized with renderer.material.mainTexture. Then isPlaying, Play() and Stop() should be called for this $$anonymous$$ovieTexture object.

In days of old, #pragma strict was optional. You could omit it and write sloppy code that would still compile at the expense of performance. Now, Unityscript is a lot more of a stickler for types, and if you're used to web JavaScript, which only infers types dynamically, you have to re-learn some things.

You should be writing, for example, var bobbingSpeed : float = 0.18;. For floats, it's not necessary, but for some things it is, and if you're in the habit of always putting a type after a variable, you will stay out of trouble.

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

16 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Weird collision error when using waypoint script... 1 Answer

Animation spins wildly after completed 0 Answers

Getting index of the smallest number in a list 1 Answer

NullReferenceException problem 2 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