- Home /
Help Me! I want to make a pixel fairy!
Hello! I am making a 2d platformer like game. The game starts in a dark cave with overworld light decreased. The player is with a 1 pixel size fairy. THE PROBLEM- 1. I want that fairy to glow and produce light moving in all directions. But I don't know how to give light like effects to game objects. 2. I want an AI script for the fairy so that she will always hover near me like an ally. 3. The cave is divided into two because of a wall. I want one side of the cave dark and the other a little bright because of a cave entrance. Can this be done? Will a directional light collide to the wall? Will the wall prevent the lighting to reach the other side of the cave? If no, is there another way? Pls HELP!!!
Answer by TheKnightsofUnity · Jul 06, 2018 at 04:50 PM
Hey @Firetrain !
Right click on your fairy GameObject -> Light -> Point Light. That should create a new child object with Light component. For a glow effect I'd advise looking for an asset on the Unity Asset Store.
A simple way to achieve this would be to add a new child to your player object that would contain only a Transform component and place it somewhere besides your character. Then add a new script for controlling your fairy and attach it to the Fairy game object. Edit the script and write something along these lines:
public class FairyController : MonoBehaviour { [SerializeField] private Transform targetSpot; [SerializeField] private float moveSpeed; private void Update() { transform.position = Vector3.Lerp(transform.position, targetSpot.position, Time.deltaTime * moveSpeed); } }
Now you can drag'n'drop the player's child object to targetSpot field and experiment with moveSpeed value until you're content with how it works.
3.If you use point lights and the wall object and its material are properly set it should work as you want it to work. Try it out in editor and go back here if you have some problems with it.
Hope that helped :)
Cheers!
Can't get the code markdown to work so here's a link to the same code with clearer formatting: https://paste.ofcode.org/Zp5W26E6TeGuwe7FXzBQia
Thanks! I will try it out and tell you if any problem arises. So please keep looking into the question. I will tell you if all of it worked. THAN$$anonymous$$S AGAIN!!
Your answer
Follow this Question
Related Questions
How do I stop my sprite from jumping in the air? 1 Answer
Making the enemy follow the path of the Player,How to make the enemy follow the path of the player? 0 Answers
How to check if an object hits the ground hard enough then add explosive force around it (2D) 1 Answer
Instantiate a GameObject with a specific Z rotation 2 Answers
Exchange player position to only 3 possible places with a platform 1 Answer