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 Veerababu.g · Jan 04, 2016 at 09:48 AM · transformmousepositionpositioning

how can my move a obect alon with the player

check the bellow pic. the green one is my player and the red one is obstacle when i tap the player has to come along with the obstacle . am doing Lerp for the movement of player whenver it collides am making the obstacle as a child to the player. it done the job job but not properly.

i mean some overlapping is there like in the 2nd fig. because of the speed it is going like that.

how can i do it.alt text

oddyess1.png (6.5 kB)
oddyess.png (3.8 kB)
Comment
Add comment · Show 2
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 RyFridge · Jan 04, 2016 at 11:04 AM 0
Share

If possible, edit your question to be more readable please. :) I understand you want to place something like a marker (obstacle) that the player will be moving towards. When the player reaches the marker, it should "disappear"?

avatar image Veerababu.g · Jan 04, 2016 at 12:28 PM 0
Share

thanks @RyFridge

it won't disappear.the player movement is grid wise. it has to move 1step up,down,left,right... according to user input(i mean in which way he swipe). if there is cube(obstacle) on the way it has to take that cube along(or it has to push that obstacle).for swipe am done it exactly what i need.

But there is a another control that is tap. if the user tap on horizontal or vertical grids to the player it has to move on which grid he tap. that is also did.

now suppose on the way(the movement is going when user tap) of the player obstacle is there.the player has to push that cube to the position where he tap.

see the bellow pic i think u can understood better.alt text

oddyessnew.png (15.0 kB)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by RyFridge · Jan 04, 2016 at 03:40 PM

Okay, I think I understood the mechanics. Now, what is the problem? What do you mean by "overlapping"?

What I would do to move things in a 2D game is to have a two-dimensional int array (the field) which knows where the player and the obstacles are. For example 0 means it is empty, 1 means it is an obstacle, 2 the player.

Now I would create some Instances for my Obstacles and my Player (GameObjects with a script). When I tap for example, I can check which Obstacles or Player are in the tapped line, calculate where they need to go by checking if there are other objects in the way and call a Obstacle.move(int x, int y); function on the Obstacles and Player respectively to tell them where to go (they can lerp it nicely on their own Update functions). After that, just update your field array where it is needed.

Does that help or is there another problem?

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 Veerababu.g · Jan 05, 2016 at 04:59 AM

thanks again @ RyFridge am already did that what you said above.By using the above concept there is non uni sync between the player and obstacle.i mean player move with one speed and the obstacle move another speed . the only solution solution is whenever it is colliding make the obstacle as child.

my problem(overlapping) is solved .what i did is whenever it(obstacle) is colliding with the player am making it as a child to the player and am giving suitable position to the obstacle.

thanks,,,,

Comment
Add comment · Show 1 · 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 RyFridge · Jan 05, 2016 at 03:12 PM 0
Share

No problem. I'm happy you got it working!

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

39 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 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

How do I draw a local space line render between parent and child objects ? 1 Answer

Calculate a point in space based on a triangle 0 Answers

iscometric grid panning 0 Answers

InverseTransformVector not changing frame of reference? 0 Answers

How to instantiate Object to specific location? 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