Download

Movable Decals help.

So I got somehow some movable decals but the thing is that I’d like to have decals moving instead of instancing them and detaching them all the time it’s annoying though it looks good.

Code here they are called in postbeginplay() function in some loops with timers ( You know what I mean ). I’d like to have a movable decal. Any idea on how to?

//Here if the pawn is sleected it instances a decal.
function SpawnAndDecalAndDestroyLater_TimerBased()
{
//SpawnedDecal.DetachFromAny();

if(bSelected)
{
Self.AttachADecalOnFloorOfPawn( Self );
}

}

//Here it gets detached.
function ClearSpawnedDecalsFromFloor_TimerBased()
{
local int I;

for( I = 0; I < SpawnedDecalsOfSelection.length; I++ )
{
     SpawnedDecalsOfSelection*.DetachFromAny();
}

}

//Reads the selected group and attaches and decal on it
function AttachADecalOnFloorOfPawn(GOTAMP2Pawn PawnWithDecal)
{
local Vector ActorRotationVector, ActorRotationVectorStart;
local vector HitLoc, HitNor;
local Rotator PlayerRotation;
local DecalComponent SpawnedDecal;

   PlayerRotation=PawnWithDecal.Rotation;
   PlayerRotation.pitch=-16000;

   ActorRotationvectorStart.z=ActorRotationVectorStart.z+50;
   ActorRotationVectorStart=PawnWithDecal.location+vector(PawnWithDecal.Rotation);

   ActorRotationVector=vector(PlayerRotation);
   ActorRotationVector=ActorRotationVector*100;
   ActorRotationVector= ActorRotationVector+PawnWithDecal.Location;

   Trace(HitLoc,HitNor,ActorRotationVector,ActorRotationVectorStart);


   SpawnedDecal = WorldInfo.MyDecalManager.SpawnDecal( DecalMaterial'MPGOTA22DMats.DecalOfSelectionBox',   // UMaterialInstance used for this decal.
                                 HitLoc,                         // Decal spawned at the hit location.
                          rotator(-HitNor),                 // Orient decal into the surface.
                          64, 64,  // Decal size in tangent/binormal directions.
                          256,                    // Decal size in normal direction.
                          false,                      // If TRUE, use "NoClip" codepath.
                          float(rotation.Yaw) / 1000,                              // random rotation
                          );


     SpawnedDecal.bMovableDecal = true;
     SpawnedDecal.SetTranslation( HitLoc + vect( 1000, 0, 0 ) );
     SpawnedDecalsOfSelection.addItem( SpawnedDecal );

     //`log("FROM GOTAMP2Pawn spawning a cool decal");
     //SpawnedDecal.DetachFromAny();

}

Thanks in advance help appreciated. :slight_smile:

can you elaborate more? what really is the problem here? movable decals work just fine, I don’t really get what you’re doing here :rolleyes:

Dropbox - File Deleted So got em working but it’s not so performance-friendly that is what I’m getting.

Also, please use code tags when posting code like this.


Like this