Jump to content

pick up coin

Recommended Posts

hello, it is possible, to place coins in my games and when you pass them,
it picks them up and increases a coin counter at the top of the screen, do you know how to do that ? (code)

For exemple : Mario

Share this post

Link to post

In the UpdatePhysics method for coin, I'd test for the distance between the player's vector and your coin's, then call the function for the pickup when it's in range.

I don't know the Lua equivalent but in C++ you'd need to call this:

virtual float DistanceToPoint(const Vec3& p);

 For example:

Vec3 v3_first = Vec3(0.0);
Vec3 v3_second = Vec3(1.0);
v3_first.DistanceToPoint(v3_second); // Will return distance between Vec3(0.0,0.0,0.0) and Vec3(1.0,1.0,1.0)


  • Thanks 1

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...