Hi all!
Atm i trying to understand Unreal Script and there are some strange error... I have an actor with component StaticMesh, i need it to fall down on Touch and stop falling on UnTouch. As i understood, StaticMesh actor dont react on Touch/UnTouch, but react on "Bump" instead. This option does not suit me... so i tried to add CylinderComponent to same Actor, if i don't touch Mesh and just enter cylinder volume, mesh start moving on enter and stop on leave, but if i try to stand on mesh, Touch-Untouch triggers in one time, and mesh stands still.. Problem wasn't in size of cylinder component, so i tried to Spawn() another actor with only CylinderComponent and attach it to the actor with a mesh, but i found that i can't spawn actor in same Location as parent actor and any attempts to change Child location fails.
I'd be appreciated for any advice, here are the code:
Actor with mesh
Actor with cylinder
Atm i trying to understand Unreal Script and there are some strange error... I have an actor with component StaticMesh, i need it to fall down on Touch and stop falling on UnTouch. As i understood, StaticMesh actor dont react on Touch/UnTouch, but react on "Bump" instead. This option does not suit me... so i tried to add CylinderComponent to same Actor, if i don't touch Mesh and just enter cylinder volume, mesh start moving on enter and stop on leave, but if i try to stand on mesh, Touch-Untouch triggers in one time, and mesh stands still.. Problem wasn't in size of cylinder component, so i tried to Spawn() another actor with only CylinderComponent and attach it to the actor with a mesh, but i found that i can't spawn actor in same Location as parent actor and any attempts to change Child location fails.
I'd be appreciated for any advice, here are the code:
Actor with mesh
Code:
class WGFallingPlatform extends Actor
ClassGroup(WeirdGame,WGInteractive)
placeable;
var(BaseSettings) StaticMeshComponent Mesh;
var float timeSpent;
var() float MovementSpeed;
var() const editconst DynamicLightEnvironmentComponent LightEnvironment;
/** Base cylinder component for collision */
var() editconst const CylinderComponent CylinderComponent;
var WGFallingPlatformVolume FPVolume;
var vector actorLoc;
simulated event PostBeginPlay()
{
// FPVolume = Spawn(class'WGFallingPlatformVolume', self,,self.Location);
// FPVolume.setParentActor(self);
Super.PostBeginPlay();
}
event Tick(float DeltaTime)
{
local float delta_distance;
local vector d;
timeSpent += DeltaTime;
delta_distance = (DeltaTime) * MovementSpeed;
d.Z = delta_distance;
Move(d);
}
function Touched()
{
WorldInfo.Game.Broadcast(self,"Touched");
GotoState('Moving');
}
function UnTouched()
{
WorldInfo.Game.Broadcast(self,"Touched");
GotoState('Moving');
}
event Touch(Actor Other, PrimitiveComponent OtherComp, Vector HitLocation, Vector HitNormal)
{
WorldInfo.Game.Broadcast(self,"Touched");
super.Touch(Other, OtherComp, HitLocation, HitNormal);
if (Pawn(Other) != none)
{
GotoState('Moving');
}
}
event UnTouch(Actor Other)
{
WorldInfo.Game.Broadcast(self,"UnTouched");
super.UnTouch(Other);
if (Pawn(Other) != none)
{
GotoState('Idle');
}
}
event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
{
WorldInfo.Game.Broadcast(self,"Bumped");
}
event TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{
GotoState('Moving');
}
state Moving
{
ignores TakeDamage;
Begin:
WorldInfo.Game.Broadcast(self,"Switching to move state");
}
state Dead
{
ignores TakeDamage,TakeRadiusDamage;
begin:
//ColorMesh.SetHidden(true); //Note that it's only hidden, it's still there and colliding.
}
auto state Idle
{
ignores Tick;
Begin:
//WorldInfo.Game.Broadcast(self,"FPLocation: "@FPVolume.Location);
WorldInfo.Game.Broadcast(self,"Switching to idle state");
if(FPVolume.Location != Mesh.GetPosition())
{
actorLoc = self.Location;
WorldInfo.Game.Broadcast(self,"Spawning Volume");
FPVolume = self.Spawn(class'WGFallingPlatformVolume',self,,actorLoc);
FPVolume.setParentActor(self);
//FPVolume.SetLocation(self.Location);
//FPVolume.SetRelativeLocation(self.Location);
WorldInfo.Game.Broadcast(self,FPVolume.Location);
WorldInfo.Game.Broadcast(self,self.Location);
WorldInfo.Game.Broadcast(self,Mesh.GetPosition());
}
}
DefaultProperties
{
Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
bEnabled=TRUE
End Object
Components.Add(MyLightEnvironment)
Begin Object class=StaticMeshComponent Name=BaseMesh
StaticMesh=test.Mesh.WGPlatform
LightEnvironment=MyLightEnvironment
//Translation=(X=0.0, Y=0.0, Z=-60.0)
//BlockActors=false
End Object
Components.Add(BaseMesh)
LightEnvironment=MyLightEnvironment
Mesh = BaseMesh
CollisionComponent=BaseMesh
MovementSpeed=4
/*
Begin Object Class=CylinderComponent NAME=CollisionCylinder LegacyClassName=Trigger_TriggerCylinderComponent_Class
CollideActors=true
CollisionRadius=+0060.000000
CollisionHeight=+0060.000000
bAlwaysRenderIfSelected=true
End Object
CollisionComponent=CollisionCylinder
CylinderComponent=CollisionCylinder
//CylinderComponent.
Components.Add(CollisionCylinder)*/
bCollideActors=true
bCollideWorld=true
bBlockActors=true
SupportedEvents.Add(class'SeqEvent_Touch')
}
Actor with cylinder
Code:
class WGFallingPlatformVolume extends Actor
notplaceable
ClassGroup(WeirdGame,AutoGenerated);
/** Base cylinder component for collision */
var() editconst const CylinderComponent CylinderComponent;
/** for AI, true if we have been recently triggered (so AI doesn't try to trigger it again) */
var bool bRecentlyTriggered;
/** how long bRecentlyTriggered should stay set after each triggering */
var() float AITriggerDelay;
var WGFallingPlatform parentActor;
function setParentActor(WGFallingPlatform act)
{
WorldInfo.Game.Broadcast(self,"SetParentActor ");
parentActor=act;
}
event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
{
parentActor.Touched();
}
event UnTouch(Actor Other)
{
parentActor.UnTouched();
}
defaultproperties
{
Begin Object Class=SpriteComponent Name=Sprite
Sprite=Texture2D'EditorResources.S_Trigger'
HiddenGame=False
AlwaysLoadOnClient=False
AlwaysLoadOnServer=False
SpriteCategoryName="Triggers"
End Object
Components.Add(Sprite)
Begin Object Class=CylinderComponent NAME=CollisionCylinder LegacyClassName=Trigger_TriggerCylinderComponent_Class
CollideActors=true
CollisionRadius=+0050.000000
CollisionHeight=+0060.000000
bAlwaysRenderIfSelected=true
End Object
CollisionComponent=CollisionCylinder
CylinderComponent=CollisionCylinder
Components.Add(CollisionCylinder)
bHidden=true
bCollideActors=true
bProjTarget=true
bStatic=false
bNoDelete=true
AITriggerDelay=2.0
bAlwaysRelevant = true
}