• 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
1
Question by shyuan · Dec 12, 2010 at 03:44 PM · follow

How can i make the other player follow the main player in 2D game?

this is a 2D Receiving game,I holp if main player eat an object that next the main player create another player and follow the main player(it will not be conterl).

alt text

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
1

Answer by Justin Warner · Dec 12, 2010 at 03:57 PM

Nice animation =) Giving you an up just for that... So, do you want it like that old snake game, you "eat" a bubble, the bubble goes on your back, etc. etc.?

To spawn an object, use instantiate... http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html

To have them follow/rotate to you, you can use

var target : Transform; var rotateSpeed = 0.0; var speed = 0.0;

function Update () {
var targetRotation = Quaternion.LookRotation(target.position - transform.position, Vector3.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * rotateSpeed);

 transform.Translate(0, 0, speed);

}

This'll move and rotate the object towards you... Change the rotation speed and speed up top... Or in the editor....

Hope this is what you're asking for!

Comment
Add comment · Show 4 · 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 shyuan · Dec 12, 2010 at 04:10 PM 0
Share

if i want it like Snake game ,the blue will add next the main player,and not only blue,one object will follow it.

the GameObject will down other color.

if Blue touch the other color , blue will be Destroy,if have one before blue ,them will Recurrence.

avatar image Justin Warner · Dec 12, 2010 at 04:26 PM 0
Share

I don't think I follow you... You want it so that If player touches blue, blue follows player, but if blue touches pink(?), then the blue object will be destroyed... I don't understand, sorry...

avatar image shyuan · Dec 12, 2010 at 05:20 PM 0
Share

I'm sorry for my pool english.

Will this game have players and objects,one color player can eat same color object.

At once only main player at the game ,as the time going other color player and object will down.

avatar image shyuan · Dec 12, 2010 at 05:22 PM 0
Share

http://images.plurk.com/3768203_da60a36ecbcdfdd95eab1a85a08266b3.gif

avatar image
0

Answer by Bampf · Dec 12, 2010 at 04:00 PM

A relatively cheap solution would be to have the 2nd object echo the movements (positions, or forces if you are using them) of the player, on a time delay.

If the objects are solid you may run into difficulties though if the player backtracks, running into the object that is following. Might be solveable by repeating the original trigger logic- if the main player is next to it, it stops moving, then starts following again as the player moves away.

Another approach might be to try and adapt the 3rd-person camera script, which comes with Unity and keeps a camera behind and above the player. Should be able to adapt it for 2d, and a non-camera object.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Camera rotation around player while following. 6 Answers

Enemies running when they should be following. 1 Answer

Animation Stops Unexpected. (Script included) 0 Answers

Follow camera: Player jumps on move 1 Answer

just need it to follow on y 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