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
1
Question by z7x9r0 · May 27, 2015 at 03:26 PM · 2djavascriptplatformer

2D Platformer - How Do I Replicate Inputs And Delay Them?

My game without animation sprites: http://z7r9r0.blogspot.com/2015/05/game-test-5272015.html

I'm using a health system similar to Donkey Kong Country's where the player is followed by another character as their second life/spare hit. YouTube video example: https://youtu.be/W_kI5xOQ0Lc?t=43s

Also Super Mario Galaxy's Mario Cosmic Clones copies players inputs at a delayed time which is similar to the following character effect I'm trying to replaicate. YouTube video example: https://youtu.be/MMB0Sdociw0?t=2m4s

Main question I am trying to solve is if the second character follows the players inputs how do I get the sprites and game objects to not intersect? I am using my own physics to move the player around, not Unity's physics.

Any references or outlines I should look at to accomplish this effect? I can't seem to find anything online yet. I believe I need to find something similar to the classic game Snake since the tail mimics the players inputs/position but at a delayed time. Any help in the right direction will help. I just want to start scripting this today but don't know where to start. I only know Javascript at the moment so anything in Javascript I'll be able to read and understand. Thank you.

Reddit post/comments/answers: https://www.reddit.com/r/Unity3D/comments/37gwt0/2d_platformer_how_do_i_replicate_inputs_and_delay/

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by virgiliu · May 27, 2015 at 03:35 PM

Move each input handler to a separate method, for example move the jumping logic in Jump() and call that method when jump is pressed.

After calling Jump() invoke it again for the secondary character with a short delay (a guesstimate would be around 0.5s or 0.7s) .

http://docs.unity3d.com/ScriptReference/MonoBehaviour.Invoke.html

Both game objects should have the same methods, like Jump, Move, etc, so that they can be invoked.

Or you could push the method names in an array then pop & invoke in Update().

Or add a distance joint between the game objects and make the secondary character kinematic.

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 z7x9r0 · May 27, 2015 at 03:39 PM 0
Share

Does it matter if there are moving platforms that only one character can fit on. I know from this example that when jumping onto a moving platform D$$anonymous$$ moves where the player was ins$$anonymous$$d of standing on the platform: https://youtu.be/W_kI5xOQ0Lc?t=43s

Thanks for the Unity doc page

avatar image virgiliu · May 27, 2015 at 03:48 PM 0
Share

Jumping might be tricky, especially with landing on moving platforms. You might want to treat those as a special case, for example store the landing position of the main character and on the secondary character override the jump method so that the character lands where the first one was.

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

20 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

Related Questions

Has anyone made a successful Pixel Perfect Camera script for platformer games? 2 Answers

Change gravity on button 1 Answer

I am having issues with my Jumping Script. 2 Answers

2D Platformer - Sidekick Follow Player 0 Answers

Unity 2D player sticks on platform corners 2 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