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 /
avatar image
0
Question by alpayiba · May 20, 2017 at 04:26 PM · c#2dscripting problemgameplay

Moving an object which changes direction overtime and instantiates a new clone on the last position it left

As the long title implies, I have an object which will move by a speed which can be changed, one unit at a time and when it gets to a specific position, it will change direction. While the first object is moving, another object will be instantiated in the positions it left and this new object will do exatly the same movement and follow the first one. Then a third object will be created...

It is more like a snake movement. In the attachments you can find the images for the movement that I am trying to make. Square with number 1 is the first one. The others will be instantiated later and folllow the first one.

Last 2 days I have been trying with many different methods but haven't been able to find a proper way.

2.png (9.3 kB)
3.png (10.3 kB)
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 Kishotta · May 20, 2017 at 05:02 PM

The first thing that comes to mind would be a linked list where each "link" in your chain keeps a record of it's movement, and then relays that to the link behind it.

Say, for example, the "head" of your snake moves "up", but hasn't spawned the second link yet. It sees that it does not have a "child" link, and so it spawns one at its previous location (stored in the head). After that, the head moves to the right. The head then tells the child to move up (as the head did in the first movement), the child moves up, sees that it has no child link, and spawns one at ITS previous position (stored in the child). Rinse, repeat.

Each link only needs to keep track of it's previous movement and previous position.

I hope that makes at least some sense.

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 alpayiba · May 20, 2017 at 05:22 PM 0
Share

Haven't heard about linked lists before. Thank you for the guideness.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

C# Collision Script Not Working 1 Answer

How to move objects in the hierarchy 0 Answers

enable and disable loop objects in the scene 1 Answer

I am trying to spawn multiple asteroids but only one is screen wrapping . Please help. 0 Answers

Mirror and Unity: How to store, reference, and compare connectionToServer.connectionId in one script,Mirror and Unity: How to store and compare differenct connectionToServer.connectionId in one script 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