• 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 therealpedro · Apr 21, 2015 at 12:52 PM · script error

custom script parameters doesn't refresh in event trigger inspector

Hi everyone,

I'm actually quite stuck with a weird problem... i created a script that takes care of my character movement, added to the character and everything works fine. i then created a ui.button on a canvas and added an event trigger to know when the user has his finger pressing the button or releasing (using pointer up and down). The problem is that i cannot select certain public functions in my related script nor any variables. Moreover, there is one parameter i can selct from my script which doesn't actually exist anymore !

i first though of a compilation error so here is my script...

using UnityEngine; using System.Collections;

public class character_control : MonoBehaviour {

 public CharacterController me;

 public float motion_speed = 30.0f;
 public float mousesensitivity = 2.0f;

 public float camangle = 0.0f;
 public float rotationSpeed = 0.1f;
 public float look_at_rotationSpeed = 100.0f;

 public bool can_turn = true;
 public bool smart_control = true;
 
 public float forwardspeed = 0.0f;
 public float forward_input = 0.0f;

 void Start ()
 {

 }
 
 // Update is called once per frame
 void Update ()
 {

     //update the camera angle for game purposes
     camangle = me.transform.rotation.eulerAngles.y;

     //rotation with keyboard //touchpad...
     movement();

 }


 public void movement()
 {
     if(can_turn)
     {

         if(Application.isMobilePlatform)
         {
             if ((Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Moved))
             {
                 // Get movement of the finger since last frame
                 Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
                 transform.Rotate(0, touchDeltaPosition.x * 5.0f, 0);
             }

         }
         else
         {
             transform.Rotate(0,Input.GetAxis("Horizontal")*rotationSpeed,0);

             forwardspeed = -Input.GetAxis("Vertical")*motion_speed*set_walking_direction(smart_control);
         }    

     }

     Vector3 speed = new Vector3 (0,0,forwardspeed);
     me.SimpleMove(speed);
 }

 public void set_forward_speed(float speed)
 {
     forwardspeed = speed*motion_speed*set_walking_direction(smart_control);
 }



 public int set_walking_direction(bool activated)
 {
     if(smart_control==true)
     {
         if((camangle>=90)&&(camangle<=270))
         {
             return 1;
         }
         else return -1;
     }
     else return 1;
 }

}

and here is what i can see in my inspector :

alt text

This script is attached to my player gameobject, as you can see, i can select movement() (which is a custom method) but none of the others.

more interestingly, the float forward_speed doesn't exist in my script...

any suggestions ?

thank you very much for any help.

bug.png (54.4 kB)
Comment
Add comment · Show 1
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 therealpedro · Apr 20, 2015 at 03:27 PM 0
Share

i forgot to mention that the script is understood correctly by the inspector, i can access all parameters from it. (

1 Reply

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

Answer by lordlycastle · Apr 21, 2015 at 02:13 PM

You cannot use set as prefix for method, well you can but it’s reserved for setting variable that is why the inspector thinks there is variable called forward_speed. Here is the list of reserved word. Use properties instead of that method, read up if you don’t know how to. They are used for exactly the purpose you are using the set_forward_speed function.

Comment
Add comment · Show 1 · 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 therealpedro · Apr 21, 2015 at 03:58 PM 0
Share

hi ... i just found out today ! thanks a lot for your time !

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

'parent' is not a member of 'Object'. 1 Answer

Csharp script parsing error 2 Answers

my STFPSC script has errors can anyone help me? 0 Answers

Object reference not set to an instance of an object error. 1 Answer

AddComponent() is adding 64 instances of my script to my GO 1 Answer


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