Jump & Collision (Answered)
-
- Posts: 29
- Joined: Thu Oct 25, 2007 5:58 pm
- Location: Florida
- Contact:
Jump & Collision (Answered)
Hi....
I am having a little problem with the camera(FPS)....
I create a plain terrain and i add a collition detector to it with the camera.
When i jump, everything seems to work very cool.... BUT
Whenever i put another object above the plane, and i jump on it.. the jump
seems to delay(on top of the added object)... also if i create a stair that goes really high, when i am on top of it, i can't jump at all... but when i fall to the ground again, i get able to jump with no problems...
Is it because the gravity or any values that im giving wrong or is just something i have to implement by coding??
This is the stair that i create, it looks crapy because i just create right now
to give a better idea of the jumping problem...
When i get on the boxes i can't JUMP....
Here i can jump..
Here i can't jump!!..
I am having a little problem with the camera(FPS)....
I create a plain terrain and i add a collition detector to it with the camera.
When i jump, everything seems to work very cool.... BUT
Whenever i put another object above the plane, and i jump on it.. the jump
seems to delay(on top of the added object)... also if i create a stair that goes really high, when i am on top of it, i can't jump at all... but when i fall to the ground again, i get able to jump with no problems...
Is it because the gravity or any values that im giving wrong or is just something i have to implement by coding??
This is the stair that i create, it looks crapy because i just create right now
to give a better idea of the jumping problem...
When i get on the boxes i can't JUMP....
Here i can jump..
Here i can't jump!!..
Last edited by Yellow_Yackets on Mon Nov 19, 2007 10:22 pm, edited 2 times in total.
Y_Y
-
- Posts: 29
- Joined: Thu Oct 25, 2007 5:58 pm
- Location: Florida
- Contact:
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
-
- Posts: 29
- Joined: Thu Oct 25, 2007 5:58 pm
- Location: Florida
- Contact:
No, i did not used metaselector on my boxes, i'm going to try it tonight.christianclavet wrote:Did you used the standard IRRlicht collision?
You must put all your object in the metaselector to have proper collision.
The boxes and stairs are added as OCCTREE in the metaselector?
I'll post the result after i test it.
Y_Y
-
- Posts: 29
- Joined: Thu Oct 25, 2007 5:58 pm
- Location: Florida
- Contact:
Well....
I was triying to figure out how to use the meta selector but it didn't worked out. This is how my code works:
And i try this:
Din't work
Can somebody tell me how to manage the jumping so that when i get on something other than the terrain i still could jump...
I can't really move on with my irrlicht learning before i learn how to jump because is one of the basic and needed thing on games.
(By the way my collision works perfect, is just the jumping)
HELP!
I was triying to figure out how to use the meta selector but it didn't worked out. This is how my code works:
Code: Select all
ITriangleSelector* selector = smgr->createTriangleSelectorFromBoundingBox(OJ[wh].Cube);
OJ[wh].Cube->setTriangleSelector(selector);
selector->drop();
aabbox3d<f32> box = OJ[wh].Cube->getBoundingBox();
vector3df radius = box.MaxEdge - box.getCenter();
//create collision response animator and attach it to the camera
ISceneNodeAnimator* RATRR = smgr->createCollisionResponseAnimator(
selector, MainCamera,
radius,
vector3df(0,0,0),
vector3df(0,0,0),
.00005f );
MainCamera->addAnimator(RATRR);
RATRR->drop();
Code: Select all
*ITriangleSelector* selector = smgr->createMetaTriangleSelector();
OJ[wh].Cube->setTriangleSelector(selector);
selector->drop();
Can somebody tell me how to manage the jumping so that when i get on something other than the terrain i still could jump...
I can't really move on with my irrlicht learning before i learn how to jump because is one of the basic and needed thing on games.
(By the way my collision works perfect, is just the jumping)
HELP!
Last edited by Yellow_Yackets on Sun Nov 18, 2007 5:29 am, edited 1 time in total.
Y_Y
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Hi, You must put your triangle selector in the metaselector like this:
First define it:
Then add each of your defined triangle selector to it. (So the metaselector will contain all the objects that you need to collide)
Once it's in there. When you define your Collision response Animator your define the MetaSelector instead of the selector. Like this:
Try this and tell us if it work.
First define it:
Code: Select all
scene::IMetaTriangleSelector* meta
Code: Select all
meta->addTriangleSelector(selector);
Code: Select all
//create collision response animator and attach it to the camera
ISceneNodeAnimator* RATRR = smgr->createCollisionResponseAnimator(
meta, MainCamera,
radius,
vector3df(0,0,0),
vector3df(0,0,0),
.00005f );
-
- Posts: 29
- Joined: Thu Oct 25, 2007 5:58 pm
- Location: Florida
- Contact:
When i tried that, everything seemed to work perfect. It compiled well with no erros, but when i tried to run it, it throws a DON'T SEND error
like this:
(I'm using Dev-C++ compiler.)
This is my code
What am i missing?
like this:
(I'm using Dev-C++ compiler.)
This is my code
Code: Select all
IMetaTriangleSelector* metal;
ITriangleSelector* selector = smgr->createTriangleSelectorFromBoundingBox(OJ[wh].Cube);
OJ[wh].Cube->setTriangleSelector(selector);
selector->drop();
metal->addTriangleSelector(selector);
aabbox3d<f32> box = OJ[wh].Cube->getBoundingBox();
vector3df radius = box.MaxEdge - box.getCenter();
ISceneNodeAnimator* RATRR = smgr->createCollisionResponseAnimator(
metal, MainCamera,
radius,
vector3df(0,0,0),
vector3df(0,0,0),
.00005f );
MainCamera->addAnimator(RATRR);
RATRR->drop();
Y_Y
Christian skipped one very important step. Creating the meta selector. As your code is right now, you have a pointer to garbage that you are calling a meta selector. That won't work well.
You also need to add triangle selectors for each of your scene nodes to the meta selector. If you have 20 collidable boxes, you need to create selectors for each of them, and add those selectors to a meta selector.
Travis
You also need to add triangle selectors for each of your scene nodes to the meta selector. If you have 20 collidable boxes, you need to create selectors for each of them, and add those selectors to a meta selector.
Travis
-
- Posts: 29
- Joined: Thu Oct 25, 2007 5:58 pm
- Location: Florida
- Contact:
I have a FOR loop that adds to all the boxes the metaselector.
Now it RUNs very COOL but with the same problem.
CODE:
Sorry i'm a little dumb on Errors like this (:oops:)
I try this also:
It jumps well but on the boxes it doesn't do anything. So i agree that my error has something to do with the collisions.
Can somebody give me a source sample of a FPS camera that jumps cool
so that i could get an idea on what i'm doing worng. OR is there a tutorial out there that talks about jumping?
Now it RUNs very COOL but with the same problem.
CODE:
Code: Select all
IMetaTriangleSelector* meta;
ITriangleSelector* selector = smgr->createTriangleSelectorFromBoundingBox(OJ[wh].Cube);
OJ[wh].Cube->setTriangleSelector(selector);
selector->drop();
meta = smgr->createMetaTriangleSelector();
meta->addTriangleSelector(selector);
aabbox3d<f32> box = OJ[wh].Cube->getBoundingBox();
vector3df radius = box.MaxEdge - box.getCenter();
ISceneNodeAnimator* RATRR = smgr->createCollisionResponseAnimator(
meta, MainCamera,
radius,
vector3df(0,0,0),
vector3df(0,0,0),
.00005f );
MainCamera->addAnimator(RATRR);
RATRR->drop();
I try this also:
Code: Select all
if(KEY_SPACE)
{
POS = MainCamera->getPosition();
MainCamera->setPosition(vector3df(POS.X,POS.Y+99,POS.Z));
}
Can somebody give me a source sample of a FPS camera that jumps cool
so that i could get an idea on what i'm doing worng. OR is there a tutorial out there that talks about jumping?
Y_Y
That isn't what your code is showing. You need to create just one meta selector and one collision response animator.I have a FOR loop that adds to all the boxes the metaselector.
Code: Select all
// just do this once
IMetaTriangleSelector* meta = smgr->createMetaTriangleSelector();
Code: Select all
for (u32 wh = 0; wh < N; ++wh)
{
// create selector for each cube
ITriangleSelector* selector = smgr->createTriangleSelectorFromBoundingBox(OJ[wh].Cube);
OJ[wh].Cube->setTriangleSelector(selector);
selector->drop();
// add each selector to the meta selector
meta->addTriangleSelector(selector);
}
Code: Select all
ISceneNodeAnimator* RATRR = smgr->createCollisionResponseAnimator(meta, MainCamera, 5.f, vector3df(0,0,0), vector3df(0,0,0), .00005f);
MainCamera->addAnimator(RATRR);
RATRR->drop();
Here is a quick and dirty description of how this code works.
- ISceneManager_assignTriangleSelectors(ISceneManager* smgr, IFileSystem* ifs) generates collision information for every oct tree, mesh, animated mesh, terrain and cube scene node in the scene indicated by smgr. It does this by calling the next function. When this function returns, all of the collidable node types mentioned above will have their own triangle selector assigned.
- ISceneNode_assignTriangleSelectors(ISceneNode* node, ISceneManager* smgr, IFileSystem* ifs) assigns a triangle selector to the scene node node by calling the next function. It then calls itself recursively, so every node in the scene graph will have had this function called on itself.
- ISceneNode_assignTriangleSelector(ISceneNode* node, ISceneManager* smgr, IFileSystem* ifs) creates a triangle selector for the scene node node if possible. This code only works for oct tree, mesh, animated mesh, terrain and cube scene nodes. You could modify it to support other node types if you wanted, and you could modify it to create the selectors differently also [use a different lod for the terrain, or different parameters for the oct tree selector].
- ISceneManager_gatherTriangleSelectors(ISceneManager* smgr, IMetaTriangleSelector* meta) recursively gathers triangle selectors for all scene nodes that have them. All selectors are put into the meta selector. You could modify this function to filter which nodes are added or not. You could filter by name, id, address, or anything else if you felt the need.
- ISceneNode_gatherTriangleSelectors(ISceneNode* node, IMetaTriangleSelector* meta) adds the selector for node, if it has one, to meta, and then calls itself recursively on the children of node. This effectively gathers all selectors from node and all of its children/grandchildren/great-grand... into meta.
Travis
-
- Posts: 29
- Joined: Thu Oct 25, 2007 5:58 pm
- Location: Florida
- Contact:
It works perfectly now!!!!!
Thanks so much Vitek!!!!
I did exactly as you told me.
1. Create a meta collision
2. Assign the collisions to the selector
3. Then assign the meta to the selector
It works COOL....
Thanks again.
Thanks so much Vitek!!!!
I did exactly as you told me.
1. Create a meta collision
2. Assign the collisions to the selector
3. Then assign the meta to the selector
It works COOL....
Thanks again.
ThanksIf somebody has the same problem and if at this point can't figure out
just ask here and I'll put a sample source code (if needed) because i think Vitek explanation is enough so i don't think i need to put the source).
Y_Y