![]() |
|
|
#21 | |
|
Quote:
|
||
|
|
|
|
|
#22 |
|
I made helping actor, now bone rotation working on client, but vector and rotations doesn't read from kactor, because on client bones rotates to zero vector:
http://s013.radikal.ru/i325/1108/5c/b5f09f697bfa.jpg Code:
class BoneRotatingActor extends Actor;
var EvilCatModern Chassis;
const TIRE_FRONT_RIGHT = 'TIRE';
const TIRE_FRONT_LEFT = 'TIRE03';
const TIRE_REAR_RIGHT = 'TIRE02';
const TIRE_REAR_LEFT = 'TIRE04';
simulated event Tick(float DeltaTime)
{
local rotator Tire1RotT, Tire2RotT, Tire3RotT, Tire4RotT, ChassisRot;
local vector Dir;
ChassisRot = Chassis.Rotation;
Dir = vector(ChassisRot);
Tire1RotT = Chassis.SteerTireRight.Rotation; // tires are invisible kactors
Tire2RotT = Chassis.SteerTireLeft.Rotation;
Tire3RotT = Chassis.EngTireRight.Rotation;
Tire4RotT = Chassis.EngTireLeft.Rotation;
Chassis.SetBoneDirection( TIRE_FRONT_RIGHT , Tire1RotT , Dir , 1 );
Chassis.SetBoneDirection( TIRE_FRONT_LEFT , Tire2RotT , Dir , 1 );
Chassis.SetBoneDirection( TIRE_REAR_RIGHT , Tire3RotT , Dir , 1 );
Chassis.SetBoneDirection( TIRE_REAR_LEFT , Tire4RotT , Dir , 1 );
}
defaultproperties
{
RemoteRole=ROLE_None
}
Code:
class EvilCatModern extends KarmaCarVehicle;
var BoneRotatingActor HelperActor;
simulated event PreBeginPlay()
{
Super.PreBeginPlay();
// Only need the helper on client, listen server and SP
if (Level.NetMode != NM_DedicatedServer)
{
HelperActor = Spawn( class'BoneRotatingActor' );
HelperActor.Chassis = self;
}
}
simulated function Destroyed()
{
Super.Destroyed();
if(HelperActor != None)
HelperActor.Destroy();
}
defaultproperties
{
RemoteRole=ROLE_DumbProxy
}
Last edited by EvilT-ModZ; 12th Aug 2011 at 05:47 AM. |
|
|
|
|
|
|
#23 |
|
Sorry I guess it's not very clear. The values you need aren't replicated on the KActor itself so you can either replicate them yourself on that Actor, or in your helper, it really doesn't make a huge difference. I've modified your code to show how this could be achieved, I've marked the changes in red so you can see what's changed.
One thing to note is that since we're now replicating the helper actor (remoterole is now simulatedproxy on the helper itself) you don't need to (in fact shouldn't) spawn it on the client, just on the server. Code:
class BoneRotatingActor extends Actor;
const TIRE_FRONT_RIGHT = 'TIRE';
const TIRE_FRONT_LEFT = 'TIRE03';
const TIRE_REAR_RIGHT = 'TIRE02';
const TIRE_REAR_LEFT = 'TIRE04';
var EvilCatModern Chassis;
// These variables calculated server-side then sent to client
var rotator Tire1RotT, Tire2RotT, Tire3RotT, Tire4RotT;
var vector Dir;
replication
{
// Send calculated variables to client
unreliable if (Role == ROLE_Authority)
Chassis, Dir, Tire1RotT, Tire2RotT, Tire3RotT, Tire4RotT;
}
simulated event Tick(float DeltaTime)
{
local rotator ChassisRot;
// Check whether chassis is valid, otherwise will get
// "Accessed None" before replication is completed
if (Chassis == None) return;
// Only update this stuff server-side
if (Role == ROLE_Authority)
{
ChassisRot = Chassis.Rotation;
Dir = vector(ChassisRot);
Tire1RotT = Chassis.SteerTireRight.Rotation; // tires are invisible kactors
Tire2RotT = Chassis.SteerTireLeft.Rotation;
Tire3RotT = Chassis.EngTireRight.Rotation;
Tire4RotT = Chassis.EngTireLeft.Rotation;
}
Chassis.SetBoneDirection( TIRE_FRONT_RIGHT , Tire1RotT , Dir , 1 );
Chassis.SetBoneDirection( TIRE_FRONT_LEFT , Tire2RotT , Dir , 1 );
Chassis.SetBoneDirection( TIRE_REAR_RIGHT , Tire3RotT , Dir , 1 );
Chassis.SetBoneDirection( TIRE_REAR_LEFT , Tire4RotT , Dir , 1 );
}
defaultproperties
{
RemoteRole=ROLE_SimulatedProxy
}
Code:
class EvilCatModern extends KarmaCarVehicle;
var BoneRotatingActor HelperActor;
simulated event PreBeginPlay()
{
Super.PreBeginPlay();
// Only spawn the helper server-side, it will be
// replicated to the client
if (Role == ROLE_Authority)
{
HelperActor = Spawn( class'BoneRotatingActor' );
HelperActor.Chassis = self;
}
}
simulated function Destroyed()
{
Super.Destroyed();
if (HelperActor != None)
{
HelperActor.Destroy();
HelperActor = None;
}
}
defaultproperties
{
RemoteRole=ROLE_DumbProxy
}
|
|
|
|
|
|
|
#24 | |
|
Quote:
![]() Now bones rotates well
|
||
|
|
|
![]() |
| Tags |
| bone, boning, postal 2, rotating |
| Thread Tools | |
| Display Modes | |
|
|