The future of my work

Time is transforming me and so is my painting. I do not believe that in a few months I will be doing the same thing today. I’m studying, watching, learning. I feel that things are changing very fast…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Be lazy and Attract powerups

To grab powerups with the use of the C key rather than the pedestrian way of going to them ourselves.

Wouldn’t it be nice if we could just grab it from here?

To achieve our laziness we need to create an empty GameObject called Grabber attached to all of our powerups as a child.

Put the following components on the object

Then edit the collider so that it is very big as that is what we will use to make the grab

Create the ColliderHelp script with the following code

OnTriggerStay2D is used and not the usual OnTriggerEnter2D as the later only checks if we collided once and then stops checking we want it to check all the time we are in the collider. Using the Vector3.MoveTowards method requires 3 things first we need the location we are starting at which will be the transform position of this GameObject(Grabber). Second we need to know where are moving towards and finally, we need to know how fast. Don’t forget to destroy this gameobject as we don’t want a bunch of colliders sticking around.

Add a comment

Related posts:

Magical Mystery Tour

Thrifty Word Challenge Roundup #45 & #24: Magic. “Magical Mystery Tour” is published by Marla Bishop in The Bad Influence.

5 Best Practices I Learned at Techstars

Best practices that my team learned to land investor deals, maximize productivity in meetings, and move our business up and to the right at Techstars Boulder.