|
|
#1 |
|
Join Date: Aug 2012
Reputation: 0
Posts: 5
|
Variables resetting
Hi.
I'm fairly new with the source engine and im experiencing some problems. I have high experience in c++ and I have worked with UDK so I have worked with 3D engines before. With that said I'm having som problems with sdk_gamemovement. I'm altering this file to alter the movement in game. Code:
void CSDKGameMovement::calculateHowToMove(CBasePlayer *pBasePlayer, CMoveData *pMove)
{
//test is a float in global scope.
DevMsg("Test = : %.2f \n", test);
if(pBasePlayer->m_playerDestination.x != 0)
{
test = 400;
}
}
To be able to work around it I need to save the correct value and work with that but it seems impossible at this moment. This is the only use of the variable test but still it prints 0 half of the time. The enly reason I see for test to becoming 0 is if the instance of this class is removed and then created again but in that case test would always equal 0 so that can't be it. So I ask you: Why does test become 0 without me assigning it to 0? |
|
|
|
|
|
#2 |
![]() Join Date: Jun 2009
Reputation: 34
Posts: 86
|
It's a bit hard to say without seeing all the code, but I think m_playerDestination is networked incorrectly. So on the client it is always 0 and you never set test to 400 on the client.
The gamemovement code runs on both the server and client (prediction), so half of the time you are printing the test variable of the client, which you have never set. |
|
|
|
|
|
#3 |
|
Join Date: Aug 2012
Reputation: 0
Posts: 5
|
Thanks for the answer, i'm going to look into this.
|
|
|
|
|
|
#4 |
|
Join Date: Aug 2012
Reputation: 0
Posts: 5
|
Yes, you were right, the client is not receiving the value properly. Now I jsut gotta find a way to fix it. But its alot easier when I know what im dealing with. Thanks again.
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|