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 /
avatar image
0
Question by MaxieGast · Dec 26, 2015 at 11:15 AM · movementphysicsmovingfrictionmoving platform

Object always falling off moving platform

I'm currently working on a game, where I need a ball to be balanced on a platform. And you can move the platform, the problem is when i move the platform the ball won't stay on the platform, it will just fall off. In real life the ball would stay on with a slow speed, but when you move the thing too fast it will fall off. I know you can use the parenting trick, and other coding things. But I need it to be real physics, to make it more realistic. for instance: by using friction or something. I tried changing the friction of the physic material but nothing seemed to happen.

So my question is, can I make it stay on the platform by using pure physics and how? If I can't what alternative methods can I use?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by JimNero_009 · Dec 26, 2015 at 03:37 PM

Speaking from a pure physics point of view, an object will stay motionless on a surface so long as the force trying to move the object is such that it is not enough to overcome the object's coefficient of static friction. In other words, the more friction something has, the more force you need to exert in order to move it. So changing the friction settings of the platform and ball is certainly the right thing to do.

However, with moving platforms in games a common thing to do is directly change the position vector of the platform in order to get the movement. This means that actually no force is being applied to the ball that is resting on top of it - the platform is just being systematically put in different places at a time scale small enough to make it seem as if it's moving naturally. If you look at the velocity of the platform at any given point, though, you will find it to be zero. If you want to achieve a real world physics effect, you would have to apply a rigidbody component to the platform and manipulate its movement by applying forces on it or manipulating the velocity vector in a sensible way. I imagine this is what is being missed right now.

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

Answer by $$anonymous$$ · Mar 07, 2020 at 06:34 PM

This is an example of how to do what @JimNero_009 is talking about. For more information about how to add force: https://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 //MonoBehavior has a bunch of methods that are called during 
 //      the lifecycyle of the GameObject that this script
 //      is attached to. In our case, the platform.
 public class CubeControllerLeftRight : MonoBehaviour
 {
     //We cache these values to avoid uneccessary method calls
     //      and unecessary object creation
     public Rigidbody rigidbody;
     public Vector3 force;
     // Start is called before the first frame update
     void Start()
     {
         //GetComponent gets a component.
         //<RigidBody> filters the components and returns only 
         //  the specified type.
         rigidbody = GetComponent<Rigidbody>();
 
         //This vector says no force in the X or Y axis. 
         //Apply .1 KG of force to the Z access
         force = new Vector3(0f, 0f, .1f);
     }
 
     
     void FixedUpdate()
     {
         //The force Vector3 describes the amount of power in 3 directions
         //Input.GetAxis returns -1, 0, or 1 which controls the direction. 
         //ForceMode.Impulse means that it is a moment of push that adjusts the velocity. 
         //      As opposed to setting the velocity or acceleration in absolute terms.
         //The game is played on the Z axis. So, we have left push, no push, right push
         //      from the perspective of the camera.
         rigidbody.AddForce(force * Input.GetAxis("Horizontal"), ForceMode.Impulse);
     }
 }


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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to apply friction independent of framerate? 1 Answer

Parent and child object have same physics 1 Answer

rigidbody friction problem....HELP!! 1 Answer

How to make moving objects stack, without sliding over each other? 0 Answers

How does Unity want me to add Friction? 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