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 MaestroDrSalah · Jul 13, 2014 at 03:50 PM · charactermovingground

Moving character on a moving ground

I have to move my character player on a moving forward ground (which is actually a flying carpet) but the carpet is moving alone leaving the character to fall , So is there a way to make the character stand still on it. please I am a very beginner user and very weak with scripts , if you can give me a ready code I will be very thankful.

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 Lo0NuhtiK · Jul 13, 2014 at 04:19 PM 1
Share

When your character is on the rug, make him a child of it.

avatar image Tanshaydar · Jul 13, 2014 at 09:45 PM 0
Share

1) Has your moving object rigidbody? 2) What is the collider material? Needs some friction.

avatar image Firedan1176 · Jul 13, 2014 at 10:03 PM 0
Share

I would recommend what Lo0Nuhti$$anonymous$$ said.

If your player is a child of the carpet, he will move in the same way. Only problem is, if the carpet rotates 'upside down' or goes up, so will the player.

avatar image Tanshaydar · Jul 13, 2014 at 10:54 PM 0
Share

I wouldn't recommend childing a rigidbody to another rigidbody.

1 Reply

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

Answer by benandlucy · Jul 13, 2014 at 10:54 PM

You could do what the people above said, but it might make some other problems arise in the future.

What I would do is add a OnCollisionStay function in a script for your player object.Like so:

 var myCarpet : GameObject;
 
 function OnCollisionStay (col : Collision) {
 
    if(col.gameObject.name == myCarpet.name){
    
     transform.localPosition.x = myCarpet.transform.position.x;    
 
 }
 
 }


Don't forget to add the carpet Object to the myCarpet variable. I don't know how well this will work as I have not tested it, but hopefully it will put you on the right track. :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

charactercontroller.isgrounded not working!! 1 Answer

How to fix rotation while moving character 0 Answers

Problem with moving an imported animation 1 Answer

Moving character to a specific point ? 0 Answers

[C#] change position on one axis while moving on another 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