Making a train of items that follow player

So now I’ve got this gem sprite. I can pick it up, and have it follow me at a short distance. But what about all the other gems? Ever instance of the gem in the level, piles up in the same spot behind me.

So how would I get the same gem BP to space itself out a set number back from the first one?

Here are some fun pictures of what has happened so far.

You could just make the logic a bit more generic so that it has a target and returns a location. Then iterate through each of your gems (they need to be stored somewhere) telling each one to follow the gem before it. This will create the worm/snake effect

Essentially the first gem follows the player then each gem follows the gem in front of it.

What you have right now is 1 BP for every instance of a gem. That means that every gem will be positioned at the exact same spot when you pick it up. What you need is to add some offset that tells the gems that they have to be placed behind your character + the offset.

You can do that in several ways. For example you can have a static variable inside your BP that represents your offset. You can then adjust it when you pick up a gem and when you “drop it”. If you don’t want to use static variables, you could maybe store the offset inside your character’s BP and access/modify it every time you pick/drop a gem.

Can the Blueprint of the gem contain this information, or should there be multiple Blueprints for each gem? I’m not sure what you mean by the term “logic”.

I already have a counter to keep track of how many have been collected. What would I need to do to this, to make it offset per each?

If you need to see the rest of the item blueprint, I can post it as well.

As I said you need an offset. It will represent the distance behind your character at which the gem should be placed. Right now what you are doing is multiplying your actor’s forward vector with -100. The thing is -100 is constant, it doesn’t change and that’s why your gems are always placed at the same place. You want to replace -100 with the said offset. So you would have GetActorForwardVector * Offset. This offset can have an initial value of -100 and each time you pick a new gem you can add another 100 to it. So first gem is at -100 the next one at -200 etc etc. If you want your gems to follow you only a certain amount of time, make sure you subtract 100 from the offset so that you won’t have empty spaces. One last thing, the offset must be a static variable of your gem BP or it has to be stored inside your character.

This is not a perfect solution and there might be better ways to do it but hopefully it will give you an idea.

I would see this as a single Gem blueprint with multiple instances following one another. The logic for this would be contained in the single Gem blueprint.

Gems would have logic for being a parent and child, following and leading.

Here is a simple example using a Gem blueprint based on Character. Drop the content folder GemSnake into the content folder such as Content\GemSnake then run the testGem map. I am using some hacky Matinee events for controlling the head gem and the rest use the follow logic to follow their predefined parents. This was made in an old 4.2 build.Content

I’ve tried every logical solution I could think of, but nothing is working. What would be keeping track of how many gems have been picked up? I’ve also been trying to get the int value of the “GemCount” to do a little work, but with no luck.