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 ItzMrJohn2You · May 03, 2015 at 02:20 PM · transformpositionparentchildswipe

how to stop child object from twitching?

I'm building a character select screen that swipe. I have one main gameobject that read swiping of finger. Each character has a parent gameobject nested under this one gameobject that reads when the character is swiped out of a certain range. and I have another child gameobject that is the image of the character. So there are 3 tiers of gameobjects. When the second tier of gameobject is within 1 and -1 of world space it scales up character image and sets it to x= 0. when out of range next character is scale and x = 0. all my characters sit perfectly at zero with out any twitching, but one character does twitch. I have been trying to figure out what I did wrong. What doesn't make sense to me is all the other characters work great except this one. here is my code that handles the character scaling and setting to x = 0.

  public class ScaleCharacter : MonoBehaviour 
  {
 public Vector3         minScale;
 public Vector3        maxScale;
 public float        lerpTime;
 public GameObject    name;
 public GameObject    lockedTextGO;
 public GameObject    juggDescription;
 public GameObject    demonDescription;

 Transform            character;

 // Use this for initialization
 void Start () 
 {
     //Grabs the image of character
     foreach(Transform child in transform)
     {
         character = child;
     }
 }
 
 // Update is called once per frame
 void Update () 
 {
     if(transform.position.x < 0.999f && transform.position.x > -0.999f)
     {
         //set characters name active
         name.SetActive (true);
         //initializes the characters pos
         Vector3 characterPos = character.position;
         //Scales character up
         character.localScale = Vector3.Lerp (maxScale, minScale, 0);
         //Sets character to middle of the screen
         characterPos = new Vector3(0f, -1.0f, -5f);
         //Sets characters pos
         character.position = characterPos;
         
     }
     else{
         /*
          * What to do when the character isn't in the middle of the screen
          */ 
         name.SetActive (false);
         character.localScale = Vector3.Lerp (minScale, maxScale, 0);
         character.localPosition = Vector3.zero;
     }
 }

}

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 ItzMrJohn2You · May 03, 2015 at 02:21 PM 0
Share

This script sits in the parent GameObject to the character image.

1 Reply

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

Answer by mustafakemal · May 03, 2015 at 02:52 PM

you should check to find what is different in twitching object from other child objects. I think you must have add rigidbody or some physical component so these affect your gameobject's motion. Also check gameobjects local position in parent gameobject. good luck

Comment
Add comment · Show 3 · 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 ItzMrJohn2You · May 03, 2015 at 06:11 PM 0
Share

The only thing that I can tell, thats is different, is the twitching character has a child sprite animation attached to it.

avatar image mustafakemal · May 05, 2015 at 10:02 PM 0
Share

does animation play fluently ? Some times assets can't load in time. Esspecially when you use instantiate funtion to create copy of prefab. I check your code and i suggest that you should check lerp function bheviour. maybe you use it wrong. you can check this out

lerp tutorial

avatar image mustafakemal · May 05, 2015 at 10:12 PM 0
Share

third parametter of lerp function musn't be zero! and if you want to ittarate a value of variable you should use this variable in lerp function as second or first parameter

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

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

Related Questions

Moving parent to position of child 0 Answers

Parent transform not following child transform 0 Answers

Transform child object over time and then destroy it. 1 Answer

Problem with making child an object 2 Answers

Position of parent-Object 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