- Home /
Trail of color behind the player 2D c#
I want to make a game where the player(the ball) goes into a pool of color as you can see in the picture. when the player walks he should painting the ground he is walking on. And my question is how should i realise this I tried trailrenderer and linerenderer, but it is quite messed up and I am not sure if this is a good option. I would appreciate any help.
Answer by Brocccoli · Mar 29, 2016 at 01:24 PM
I would make a component script called ColorTrailComponent and attach it to my player.
[RequireComponent(Transform)]
public class ColorTrailComponent : MonoBehavior
{
Transform playerTransform;
void Start()
{
playerTranform = = getComponent<Transform>();
}
void Update()
{
DrawSpot();
}
protected void DrawSpot()
{
//Use the players tranform position to draw on the gameScreen. Possibly another gameObject called
//paintSpot or something, that is just a certain colored sprite and instantiate it and place it on
//the game screen at the players location, under the player
}
}
Ok thanks for the great idea it works well, but i dont want to draw the paint on spots which are already painted. $$anonymous$$aybe I can do this with a collider?
Yea, possibly.
You could have the paint sprites have a collider that causes a boolean value to toggle on in the player allowing it to drop paint or not.
Then check the boolean value in player before dropping paint.
Don't forget to upvote and accept the answer if it helped you.
Your answer
Follow this Question
Related Questions
iTween: How to animate other shader-color values besides the main Color? 1 Answer
How do I play the same animation in other places in the game world? 1 Answer
How To Make Enemy Chase You? 1 Answer
Character Controller Component, Gravity/inertia, and Root Motion 0 Answers
Text displays during animation 1 Answer