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 Godsweeper · Sep 16, 2013 at 03:59 PM · move an objectbasic programming

Character falls through platform when moving with the mouse

Hello,

I'm taking my first steps with Unity and have got a basic 2D auto-running platformer going. My problem is that I've created a platform that the player needs to move with the mouse (or touch screen) to link two sections of ground so the character can safely run across.

This works fine if you move the platform before the character gets there, but if you move the platform too quickly when the character is already on it, they will fall through the bottom of it. Moving the platform slowly will work though.

How can I match the character's y-axis speed to the speed of the platform when moving it with the mouse?

Comment
Add comment · Show 4
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 vexe · Sep 16, 2013 at 04:08 PM 0
Share

Could you give us more info about your setup? What components do your player and platform have attached to them? is there a rigidbody attached to your platform? if so, is$$anonymous$$inematic should be checked eli$$anonymous$$ating all physics interaction between your player and the platform. Not sure why would you want to match y speeds...

avatar image Godsweeper · Sep 16, 2013 at 04:55 PM 0
Share

player has capsule collider and rigidbody, platform has box collider and rigidbody. If I check is$$anonymous$$inematic the player launches into the air when you select the platform with the mouse.

I thought matching the y speed would ensure that the player stayed attached to the platform regardless of how quickly the player moved it?

avatar image vexe · Sep 16, 2013 at 05:22 PM 0
Share

is the platform moving vertically? - if it was horizontally then I guess you meant x ins$$anonymous$$d of y, unless your scene is setup so that the global y is aligned horizontally.

avatar image GC1983 · Sep 16, 2013 at 06:01 PM 0
Share

It depends on how you are doing it. I would recommend using a Character Controller over a rigidbody for your PC. It also will matter on how you are moving your transform.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by YJack · Sep 16, 2013 at 05:10 PM

So, your problem is that you are taking off the ground from your player character (or that's how Unity are understanding this). I'm not sure if you can solve this by simple change the Collision Detection parameter from your rigidbody. Probably you will need a more severe solution.

Try some adjustment with you colliders before try the solution below.

If you put your character parented to your plarform when the player try to move your platform with the player over it... well... maybe this can solve your problem.

To do this use: transform.parent = (your platform transform)

Comment
Add comment · Show 2 · 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 Godsweeper · Sep 17, 2013 at 11:37 AM 0
Share

The code I have currently for dragging the platform is:

 function On$$anonymous$$ouseDown () {
         can$$anonymous$$ove = true;
         myTransform.Translate(Vector3.up*addHeightWhenClicked);
         gravitySetting = myRigidbody.useGravity;
         freezeRotationSetting = myRigidbody.freezeRotation;
         myRigidbody.useGravity = false;
         myRigidbody.freezeRotation = freezeRotationOnDrag;
         yPos = myTransform.position.y;
     }

While to parent the player to the platform I have this:

 function OnCollisionStay (hit : Collision) { 
     if(hit.gameObject.tag == "platform"){
         transform.parent = transform; 
     }else{
         transform.parent = null;
 }
 }

$$anonymous$$y player character only falls through the platform when it is dragged quickly, otherwise it's fine :\

avatar image GC1983 · Sep 17, 2013 at 04:27 PM 0
Share

Whats the point of creating the variable for rigidbody.useGravity if youre not using it?

You have

gravitySetting = rigidbody.useGravity; rigidbody.useGravity = false;

And why parent the player to the platform?

Also, keep in $$anonymous$$d your last response is not an answer.

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

18 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

Related Questions

Why do my triggers not work when I build my game? 0 Answers

String segment comparator 1 Answer

2 Programming Languages 4 Answers

How to make a button go through Gameobjects one at a time.? 0 Answers

Replace A Component Then Crashes 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