Hi People, sorry for my english,
I make my first game and I wish to make that player can pickup something
for example when player approach to NPC, he can press "action-key" and talk with him or when walk near bonus, he can pickup him.
I wanted make its with collision model, but i don`t know how re-define this event, player only stoped, As though before it a wall.
In advance thanks, yours faithfully Sergey.
Pickup object (bonus,weapon, etc)
Pickup object (bonus,weapon, etc)
from Russia with love )))
-
- Posts: 326
- Joined: Wed Dec 14, 2005 10:08 pm
I'm using a different method.
I created a line in front of the player, pointing at where he looks.
Then, when the "action" key is pressed I check for two things: if the object I want to interact with is in front of the player (intersects the line), and if the distance to that object from the player is a specific amount.
If those two conditions return true, then your player is in front of an object that he can pick up/interact with.
Hope this helps.
I created a line in front of the player, pointing at where he looks.
Then, when the "action" key is pressed I check for two things: if the object I want to interact with is in front of the player (intersects the line), and if the distance to that object from the player is a specific amount.
If those two conditions return true, then your player is in front of an object that he can pick up/interact with.
Hope this helps.
i relying that it uses
function?
in this case does not need to check the length, or use another method?
passing the question: What is idBitMask?
Code: Select all
virtual ISceneNode * ISceneCollisionManager::getSceneNodeFromRayBB (core::line3d< f32 > ray, s32 idBitMask=0, bool bNoDebugObjects=false)=0
in this case does not need to check the length, or use another method?
passing the question: What is idBitMask?
from Russia with love )))
you have an array for your npcs right?
then easy
then easy
Code: Select all
for (int i = 0; i < npcs.size(); i++)
{
if (npcs[i]->getPosition().getDistanceFrom(node->getPosition() < 50)
{
// the npc is within a circle radius 50
// check if its before the player
}
}
Re:
WooooW Thanks in Advance.andrei25ni wrote:I'm using a different method.
I created a line in front of the player, pointing at where he looks.
Then, when the "action" key is pressed I check for two things: if the object I want to interact with is in front of the player (intersects the line), and if the distance to that object from the player is a specific amount.
If those two conditions return true, then your player is in front of an object that he can pick up/interact with.
Hope this helps.
I was just at some of this moments where you are unhappy with your idea on how to implement the next step and then I saw your post.
Btw I will not use a line: smgr.getSceneCollisionManager.getSceneNodeFromScreenCoordinatesBB(getVector2dip(MouseState.Position.X,MouseState.Position.Y));
(I play around with a fps game).
Have a nice day
Re: Pickup object (bonus,weapon, etc)
You want to make sure your collision radius is close to the character.
You might want to get the approximate radius:
To get the character Actual boundingbox = originalBoundingbox*scale
radius = SQRT( (0.5*baseBoxWidth)^2 + (0.5*baseBoxLength)^2 ) + someOffset
Regards
thanh
You might want to get the approximate radius:
To get the character Actual boundingbox = originalBoundingbox*scale
radius = SQRT( (0.5*baseBoxWidth)^2 + (0.5*baseBoxLength)^2 ) + someOffset
Regards
thanh
Re: Pickup object (bonus,weapon, etc)
Or calculating
long DIST ;
and using square-distances and checking at them (so not using sqrt which is slow).
someOffset must be then squared as well.
long DIST ;
and using square-distances and checking at them (so not using sqrt which is slow).
someOffset must be then squared as well.
Re: Pickup object (bonus,weapon, etc)
.
SomeOffSet is not square. It's an estimated gap.
Or just using
max(lengh, width)
SomeOffSet is not square. It's an estimated gap.
Or just using
max(lengh, width)