Ive made a karma ball which works fine if i put it into a map in unrealed.
I coded it to use it as a powerup: (the powerup spans this class underneath, but it doesnt work...)
this is my code for the ball itself
The code above the defaultproperties are for multiplayer, something has to be wrong in my defaultproperties I think...
I dont know if this coding is right but I cant even summon the ball.
I coded it to use it as a powerup: (the powerup spans this class underneath, but it doesnt work...)
this is my code for the ball itself
Code:
class RcBal extends KActor
placeable;
var() float MaxNetUpdateInterval;
var float NextNetUpdateTime;
var KRigidBodyState KState, KRepState;
var bool bNewKState;
var int StateCount, LastStateCount;
replication
{
unreliable if(Role == ROLE_Authority)
KRepState, StateCount;
}
function Tick(float Delta)
{
PackState();
}
//Pack current state to be replicated
function PackState()
{
local bool bChanged;
if(!KIsAwake())
return;
KGetRigidBodyState(KState);
bChanged = Level.TimeSeconds > NextNetUpdateTime;
bChanged = bChanged || VSize(KRBVecToVector(KState.Position) - KRBVecToVector(KRepState.Position)) > 5;
bChanged = bChanged || VSize(KRBVecToVector(KState.LinVel) - KRBVecToVector(KRepState.LinVel)) > 1;
bChanged = bChanged || VSize(KRBVecToVector(KState.AngVel) - KRBVecToVector(KRepState.AngVel)) > 1;
if(bChanged)
{
NextNetUpdateTime = Level.TimeSeconds + MaxNetUpdateInterval;
KRepState = KState;
StateCount++;
}
else
return;
}
//New state recieved.
simulated event PostNetReceive()
{
if(StateCount == LastStateCount)
return;
}
//Apply new state.
simulated event bool KUpdateState(out KRigidBodyState newState)
{
//This should never get called on the server - but just in case!
if(Role == ROLE_Authority || StateCount == LastStateCount)
return false;
//Apply received data as new position of actor.
newState = KRepState;
StateCount = LastStateCount;
return true;
}
defaultproperties
{
MaxNetUpdateInterval=0.5
Physics=PHYS_Karma
StaticMesh=StaticMesh'RcStatic.bal'
bAlwaysRelevant=True
RemoteRole=ROLE_SimulatedProxy
bNetNotify=True
Begin Object Class=KarmaParams Name=KarmaParams0
Kmass=2.5000000
KStartEnabled=True
bClientOnly=False
bKAllowRotate=True
KFriction=1.000000
KRestitution=1.000000
KImpactThreshold=1.000000
Name="KarmaParams0"
End Object
KParams=KarmaParams'RcRacing.RcBal.KarmaParams0'
drawScale=0.5;
}
The code above the defaultproperties are for multiplayer, something has to be wrong in my defaultproperties I think...
I dont know if this coding is right but I cant even summon the ball.
Last edited by a moderator: