- Home /
How to form copies of yourself that follow you when you walk? (2D Platformer)
Is this possible? In my 2D platformer; I want to make copies of myself whenever I walk? Is there something like this that duplicates the player every x seconds so it would look like the player has copies behind him when he walks that would follow him around?
Something like this: http://www.advancedanime.com/pictures/normal_sonic88run.jpg
Thanks guys, I appreciate any help
for sure, just do what is explained.
NOTE - generally you just make iN ADVANCE say ten copies of the object, and then move them around. Don't literally instantiate them on the fly. O$$anonymous$$?
Alright, that sounds good. These are good suggestions and I know what I'm doing now. Thanks guys
Answer by ColinBurke · Jun 22, 2012 at 09:20 PM
Absolutely, just copy the character object, and offset it's position, perhaps relative to the player's velocity? Alliteratively, you could store the player's past positions and use them to place the copies. You could then change the character's material's color value to simulate a fading effect.
So, yes it's entirely possible with some simple code.
Answer by gregzo · Jun 22, 2012 at 09:13 PM
If you have pro, you could use motion blur, which judging by your example pic is what you're after.
If you want more precise copies, specialy in a 2d game, why not simply clone your sprite with a time/space offset and a decreasing alpha? If your prefab has an alpha var and a delayToInput var, it shouldn't be impossible to fake.
Very rough pseudo code, just to give the gist of things:
var delay : float; //set this to 0 on your main sprite
var alpha : float; //set this to 1 on your main sprite
var xOffset : float; //set this to 0 on your main sprite
thisSprite.alpha = alpha;
thisSprite.position.x += xOffset;
function RunRight()
{
yield WaitForSeconds(delay);
RunRightNow();
}
If you have 4 or 5 instances of your main sprite, whith quite a bit of experimenting and tweaking, this kind of approach could work. You'd have to do some lerping around, and just see what works for you! Did a much simpler but somewhat similar thing recently, faking reflections.
Your answer
Follow this Question
Related Questions
Score system 1 Answer
How to handle a MASSIVE amount of game objects? 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
creating a 2d game object like doom 2 Answers