It looks like you're new here. If you want to get involved, click one of these buttons!
Hello there. So.... I'll just right into it. I'm not a very knowledgeable programmer, but I know enough to get by with minimal code and mechanics.
Lately, I've begun to create a new project in which I am undertaking a different approach to pickups.
To explain, the idea is to approach a game item, press "E", send out a Raycast2D, and change the transform.position of the game item from on the ground to in the players "hands" (its just another transform point). Then, pressing "E" again to drop the item.
I have the first 2 and a half things down. I can approach a game item and upon pressing "E", a Raycast2D goes out and confirms to hit the desired item.
The issue I'm running into now, is actually changing the position of the game item from on the ground to the players grasp.
What can I do in order to use the Raycast2D to pick up a game item?
Raycast2D returns the RaycastHit of what it hits.
So Physics2D.Raycast([insert values here]).transform is the transform of the object you hit.
RaycastHit2D rayHit = Physics2D.Raycast([insert values here]); if(rayHit.collider != null) { rayHit.transform.position = // put your hand position here }
Answers
@Mouledoux , that worked a freaking charm! Thank you so very much!