Is there a way to do something like
playernode->getPosition();
intxpos = don'tknowhere
intypos = ""
intzpso = ""
Where the x position gets saved to the x int and so on.
Saving a players position to an int
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
do you mean like this?
Code: Select all
core::vector3df pos = playernode->getPosition();
float x = pos.X;
float y = pos.Y;
float z = pos.Z;
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
im not entirely sure what you mean.
If you mean the z float isn't being updated, well whenever you did do something like playernode->setPosition(x, y+10, z); i would actually do this:
y += 10;
and every game loop, set playernode->setPosition(core::vector3df(x, y, z));
that way it will always be where you set it to be
if thats not what you meant, please explain further.
also, its probably better just to keep the floats inside the vector3df variable. Then when you need to change them, just do pos.Y+=10; and it makes setting them easier as you get to type less: playernode->setPosition(pos);
If you mean the z float isn't being updated, well whenever you did do something like playernode->setPosition(x, y+10, z); i would actually do this:
y += 10;
and every game loop, set playernode->setPosition(core::vector3df(x, y, z));
that way it will always be where you set it to be
if thats not what you meant, please explain further.
also, its probably better just to keep the floats inside the vector3df variable. Then when you need to change them, just do pos.Y+=10; and it makes setting them easier as you get to type less: playernode->setPosition(pos);
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Code: Select all
if(event.EventType == EET_KEY_INPUT_EVENT &&
!event.KeyInput.PressedDown && event.KeyInput.Key == KEY_SPACE)
{
playermeshn->setPosition(vector3df(posx,posz+20,posy));
return true;
}
and in the main loop...
Code: Select all
vector3df pos = playermeshn->getPosition();
posx = pos.X;
posy = pos.Y;
posz = pos.Z;
your code does put you 20 into the air.
I am still unsure what you are after. I think you mean the variables being saved so you can jump anywhere.
All you need to do for that is in your even receiver, when space is pressed, do the whole thing.
and just so you know, i changed posz+20 to pos.Y+20 as the y variable is the vertical one.
I am still unsure what you are after. I think you mean the variables being saved so you can jump anywhere.
All you need to do for that is in your even receiver, when space is pressed, do the whole thing.
Code: Select all
if(event.EventType == EET_KEY_INPUT_EVENT &&
!event.KeyInput.PressedDown && event.KeyInput.Key == KEY_SPACE)
{
vector3df pos = playermeshn->getPosition();
playermeshn->setPosition(vector3df(pos.X,pos.Y+20,pos.Z));
return true;
}
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact: