Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by damon2494 · Sep 21, 2016 at 04:11 AM · physicsrigidbodycolliderplayer movementplatform

Player Movement Goes Crazy When Hit On Side Of Moving Platform

THIS IS ON PLAYER CONTROLLER SCRIPT void FixedUpdate() { if(!GameController.gameOver) {

         //let the player to move the ball
         touchControl();

         
         //set offset for ball
         transform.position = new Vector3(transform.position.x, 0.5f, transform.position.z);
         
         //prevent ball from exiting the view (downside)
         if(transform.position.z < -5) 
             transform.position = new Vector3(transform.position.x, transform.position.y, -5.0f);
         
         //prevent ball from exiting the view (Upside)
         if(transform.position.z > 4f) 
             transform.position = new Vector3(transform.position.x, transform.position.y, 4f);
         
         //left/right movement limiters
         if(transform.position.x > 3.1f) 
             transform.position = new Vector3(3.1f, transform.position.y, transform.position.z);
         if(transform.position.x < -3.1) 
             transform.position = new Vector3(-3.1f, transform.position.y, transform.position.z);
     }
 }

 // Control ball's position 
 
 void touchControl(){

     if (Input.GetKey (KeyCode.RightArrow)) {
     
         transform.Translate(Vector3.right * speedBall * Time.deltaTime);
     }

     if (Input.GetKey (KeyCode.LeftArrow)) {

         transform.Translate(Vector3.left * speedBall * Time.deltaTime);
     }
 }
     

 ///***********************************************************************
          ******THIS IS ON GAME CONTROLLER SCRIPT******
     /// Clone Maze item based on a simple chance factor
     ///***********************************************************************
     void cloneMaze() {
         createMaze = false;
         startPoint = new Vector3( Random.Range(-1.0f, 1.0f) , 0.5f, -7);
         Instantiate(maze[Random.Range(0, maze.Length)], startPoint, Quaternion.Euler( new Vector3(0, 0, 0)));    
         StartCoroutine(reactiveMazeCreation());
     }

 ******THIS IS ON PLATFORM MOVER******
     [Range(1.5f, 2.5f)]
     public float speed = 2.0f;                    //movement speed
     private float destroyThreshold = 10.0f;    //destory passed mazes to free up the memory
 
 
 
     void FixedUpdate() {
         //Scroll down the maze objects
         transform.position += new Vector3(0, 0, Time.deltaTime * GameController.moveSpeed * speed);
         //Destroy it if it's out of screen view
         if (transform.position.z > destroyThreshold) 
             Destroy(gameObject);
     }
         
 }

The platform(maze) will move from downwards to up and increase the speed every 10 second.

When my player(a 3D sphere) move along the edge of the platform(attached with box collider), especially when touch the side or fall on the edge of the platform, it will start to move on its own and the key button wont work ,example when i press right,the ball will move up or opposite direction or float and vice versa.

Did i wrote wrong on the script? or i missed something?

I want my player to move smooth without going crazy throughout the whole speed.

Also,i have no problem when moving left and right on the platform flat surface,only when hit the side and other platform side ,it goes crazy.

Sorry for my bad English,i'm not a native speaker.

Here is additional info: alt text alt text

left is platform(maze child) inscpector, right is sphere inspector. THANK YOU!

hierarcyplayer.png (90.4 kB)
maze.png (4.8 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Rigidbody falling not according to physics, only when script is applied. 0 Answers

Player moves indefinitely after collision 0 Answers

Physics.OverlapSphere not detecting collision! Collision help. 1 Answer

Player object can, but should not, climb walls, slingshot themselves, and given enough time, can run through the ground. 1 Answer

How to fix this problem? 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