jgg
04-06-2012, 06:56 PM
Hi all!
I have a simple object that my pawn must be able to grab, move, throw and release. Grabbing and throwing it seems to work properly, but when moving it collisions with brushes are somehow disabled. Note that collisions with other static meshes while moving it are working, but when the object is attached to my pawn (see code below) and I move around the level, which is built with BSP brushes, going through a door or getting close to a wall shows that the collision is not working although COLLIDE_BlockAll is specifically set by code. Next screenshot shows what I mean:
http://s14.postimage.org/yyfz82rq7/no_collision.png
Here is the code for the object (PSThrowableObject extends from KActor) and for the PlayerController:
Object:
class PSThrowableObjectContainer extends PSThrowableObject
placeable;
DefaultProperties
{
Begin Object class=StaticMeshComponent Name=PSThrowableObjectContainerMesh
StaticMesh=StaticMesh'PS_static_meshes.throwable.e nv_gen_container'
BlockActors=true
CollideActors=true
BlockRigidBody=true
BlockZeroExtent=true
HiddenGame=FALSE
HiddenEditor=FALSE
LightEnvironment=MyLightEnvironment
End Object
Mesh=PSThrowableObjectContainerMesh
Components.Add(PSThrowableObjectContainerMesh)
ThrowingMomentum=10000.0
}
PlayerController:
class PSPlayerController extends UDKPlayerController;
var PSThrowableObject ObjectCarrying;
// Camera zoom from console or key
exec function CameraZoom()
{
PSCamera(PlayerCamera).Zoom();
}
exec function StartFire( optional byte FireModeNum )
{
local PSGameInfo Game;
local Vector ThrowDirection;
if ( WorldInfo.Pauser == PlayerReplicationInfo )
{
SetPause( false );
return;
}
// If the player is not carrying anything, then start firing the current weapon
if ( Pawn != None && !bCinematicMode && !WorldInfo.bPlayersOnly && (ObjectCarrying == None) )
{
Pawn.StartFire(FireModeNum);
}
// If carrying an object, throw it!
else if ( Pawn != None && !bCinematicMode && !WorldInfo.bPlayersOnly && (ObjectCarrying != None) )
{
ObjectCarrying.SetPhysics(PHYS_RigidBody);
ObjectCarrying.SetCollisionType(COLLIDE_BlockAll);
ThrowDirection = Normal(vector(Rotation));
ObjectCarrying.StaticMeshComponent.AddImpulse(Thro wDirection * ObjectCarrying.GetThrowingMomentum());
ObjectCarrying.SetBase(None);
Game = PSGameInfo(WorldInfo.Game);
Game.SetSlowSpeed();
ObjectCarrying = None;
}
}
simulated function bool performedUseAction()
{
local Actor HitActor;
local vector OutLocation, HitLocation, HitNormal;
local rotator OutRotation;
OutLocation = Pawn.GetPawnViewLocation();
OutRotation = Pawn.GetViewRotation();
// Pawn already carrying an object --> release it
if( ObjectCarrying != None )
{
ObjectCarrying.SetPhysics(PHYS_RigidBody);
ObjectCarrying.SetCollisionType(COLLIDE_BlockAll);
ObjectCarrying.SetLocation(OutLocation + vect(30,0,0));
ObjectCarrying.SetBase(None);
ObjectCarrying = None;
return true;
}
// Pawn not carrying an object yet --> grab it
else
{
HitActor = Pawn.Trace(HitLocation, HitNormal, (OutLocation + vector(OutRotation) * 200), OutLocation, True);
ObjectCarrying = PSThrowableObject(HitActor);
// If the object trying to grab is a valid one, then grab it
if(ObjectCarrying != none)
{
ObjectCarrying.SetPhysics(PHYS_None);
ObjectCarrying.SetCollisionType(COLLIDE_BlockAll); // This doesn't avoid object collisions
// with brushes
ObjectCarrying.SetLocation(OutLocation + vect(0,0,80));
ObjectCarrying.SetBase(Pawn);
return true;
}
}
return super.PerformedUseAction();
}
DefaultProperties
{
CameraClass=class'PSGame.PSCamera'
ObjectCarrying=None
}
I've tried with many collision configuration variables, but they seem not to be related with the issue as they don't make any difference. I just want to move around with the object while preserving its collision interaction with both meshes (currently works) and brushes (not working when attached to the pawn). BTW, eventually the object should be attached to a socket in the pawn instead of using SetBase, so, has this any implication in the way collisions behave when moving with the object attached?
Thank so much for your help! =)
I have a simple object that my pawn must be able to grab, move, throw and release. Grabbing and throwing it seems to work properly, but when moving it collisions with brushes are somehow disabled. Note that collisions with other static meshes while moving it are working, but when the object is attached to my pawn (see code below) and I move around the level, which is built with BSP brushes, going through a door or getting close to a wall shows that the collision is not working although COLLIDE_BlockAll is specifically set by code. Next screenshot shows what I mean:
http://s14.postimage.org/yyfz82rq7/no_collision.png
Here is the code for the object (PSThrowableObject extends from KActor) and for the PlayerController:
Object:
class PSThrowableObjectContainer extends PSThrowableObject
placeable;
DefaultProperties
{
Begin Object class=StaticMeshComponent Name=PSThrowableObjectContainerMesh
StaticMesh=StaticMesh'PS_static_meshes.throwable.e nv_gen_container'
BlockActors=true
CollideActors=true
BlockRigidBody=true
BlockZeroExtent=true
HiddenGame=FALSE
HiddenEditor=FALSE
LightEnvironment=MyLightEnvironment
End Object
Mesh=PSThrowableObjectContainerMesh
Components.Add(PSThrowableObjectContainerMesh)
ThrowingMomentum=10000.0
}
PlayerController:
class PSPlayerController extends UDKPlayerController;
var PSThrowableObject ObjectCarrying;
// Camera zoom from console or key
exec function CameraZoom()
{
PSCamera(PlayerCamera).Zoom();
}
exec function StartFire( optional byte FireModeNum )
{
local PSGameInfo Game;
local Vector ThrowDirection;
if ( WorldInfo.Pauser == PlayerReplicationInfo )
{
SetPause( false );
return;
}
// If the player is not carrying anything, then start firing the current weapon
if ( Pawn != None && !bCinematicMode && !WorldInfo.bPlayersOnly && (ObjectCarrying == None) )
{
Pawn.StartFire(FireModeNum);
}
// If carrying an object, throw it!
else if ( Pawn != None && !bCinematicMode && !WorldInfo.bPlayersOnly && (ObjectCarrying != None) )
{
ObjectCarrying.SetPhysics(PHYS_RigidBody);
ObjectCarrying.SetCollisionType(COLLIDE_BlockAll);
ThrowDirection = Normal(vector(Rotation));
ObjectCarrying.StaticMeshComponent.AddImpulse(Thro wDirection * ObjectCarrying.GetThrowingMomentum());
ObjectCarrying.SetBase(None);
Game = PSGameInfo(WorldInfo.Game);
Game.SetSlowSpeed();
ObjectCarrying = None;
}
}
simulated function bool performedUseAction()
{
local Actor HitActor;
local vector OutLocation, HitLocation, HitNormal;
local rotator OutRotation;
OutLocation = Pawn.GetPawnViewLocation();
OutRotation = Pawn.GetViewRotation();
// Pawn already carrying an object --> release it
if( ObjectCarrying != None )
{
ObjectCarrying.SetPhysics(PHYS_RigidBody);
ObjectCarrying.SetCollisionType(COLLIDE_BlockAll);
ObjectCarrying.SetLocation(OutLocation + vect(30,0,0));
ObjectCarrying.SetBase(None);
ObjectCarrying = None;
return true;
}
// Pawn not carrying an object yet --> grab it
else
{
HitActor = Pawn.Trace(HitLocation, HitNormal, (OutLocation + vector(OutRotation) * 200), OutLocation, True);
ObjectCarrying = PSThrowableObject(HitActor);
// If the object trying to grab is a valid one, then grab it
if(ObjectCarrying != none)
{
ObjectCarrying.SetPhysics(PHYS_None);
ObjectCarrying.SetCollisionType(COLLIDE_BlockAll); // This doesn't avoid object collisions
// with brushes
ObjectCarrying.SetLocation(OutLocation + vect(0,0,80));
ObjectCarrying.SetBase(Pawn);
return true;
}
}
return super.PerformedUseAction();
}
DefaultProperties
{
CameraClass=class'PSGame.PSCamera'
ObjectCarrying=None
}
I've tried with many collision configuration variables, but they seem not to be related with the issue as they don't make any difference. I just want to move around with the object while preserving its collision interaction with both meshes (currently works) and brushes (not working when attached to the pawn). BTW, eventually the object should be attached to a socket in the pawn instead of using SetBase, so, has this any implication in the way collisions behave when moving with the object attached?
Thank so much for your help! =)