Announcement

Collapse
No announcement yet.

Moving a decal in runtime?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Moving a decal in runtime?

    For my RTS project (see sig) I'm currently spawning a new decal every frame of the game to create a rotating circle around a selected unit. Is there a way to have one decal and control it's location and rotation and actually see it move?
    Something not a decal but working in a similar fashion will do as well (performance being key here).

    Thanks

    #2
    Decals are the correct choice imo.

    Are you spawning a DecalActor or only a DecalComponent? DecalActors have Location and Rotation variables which can easily be updated.
    As far as I know you can either use
    Code:
    static final function SetDecalParameters( DecalComponent TheDecal,
    						MaterialInterface DecalMaterial,
    						vector DecalLocation,
    						rotator DecalOrientation,
    						float Width,
    						float Height,
    						float Thickness,
    						bool bNoClip,
    						float DecalRotation,
    						PrimitiveComponent HitComponent,
    						bool bProjectOnTerrain,
    						bool bProjectOnSkeletalMeshes,
    						name HitBone,
    						int HitNodeIndex,
    						int HitLevelIndex,
    						int InFracturedStaticMeshComponentIndex,
    						float DepthBias,
    						vector2D BlendRange
    						)
    or
    Code:
    native function SetTranslation(vector NewTranslation);
    native function SetRotation(rotator NewRotation);
    in order to move/rotate DecalComponents.

    Comment


      #3
      Hmm, that didn't work last time, I'll try it again maybe I missed something as it was a while ago.

      Comment


        #4
        Sorry, what didn't work?

        If you mean the default DecalActor: it's supposed to NOT being spawnable. You can write your own DecalActor subclass with bStatic set to false in the defaultproperties or try DecalActorMovable as this has bStatic already at false.

        Comment


          #5
          SetTranslation() and SetRotation() didn't work, trying to spawn Decals outside DecalManager resulted in no decals. I also don't seem to be able to give the DecalActor the decal I want (editconst const it set on it).

          Comment


            #6
            Check your log if you're trying to spawn decals outside decalmanager with "Spawn();" function. It should give you some info about why it can't spawn.

            To set a different DecalMaterial all you need is a reference to a DecalComponent and a Material. Then you can use "YourDecalComponent.SetDecalMaterial(YourMaterial) ;".

            Works awesome with my own RTS project; not based on your framework, which is a great piece of work

            Comment


              #7
              Oh silly me, bNoDelte was set to true.
              Thanks, it works now

              And thanks for the compliment, I apreciate it.

              Comment


                #8
                Decal? Why not use a particle system?

                Comment


                  #9
                  cause particles are expensive? correct me if i'm wrong

                  Comment


                    #10
                    I thought that as well. In my framework one can use a particle system instead of a decal if that is desired (it does require some coding though).

                    Comment


                      #11
                      Originally posted by UnrealEverything View Post
                      cause particles are expensive? correct me if i'm wrong
                      Cheaper than decals. With a particle you render something like a single plane. With a decal you render double the geometry that that decal covers.

                      Comment


                        #12
                        Hey would you mind sharing the code on how to do that component . I can really use that for less processing

                        Comment


                          #13
                          @ambershee: Ah you mean a single particle, that is actually a pretty good idea... it is less graphically pleasing than a decal on uneven terrain but a good idea maybe for lower end machine setting, I'll look into it, thanks for the tip.

                          @Pranav: It will be in the next release of my framework, but since you probably don't want to wait for it:
                          Code:
                          function drawSelectionEffect(float DeltaTime) {
                          	local Vector groundLocation;
                          	local Vector groundNormal;
                          	local Rotator DecalRotation;
                          
                          	Trace(groundLocation, groundNormal, Pawn.Location + vect(0,0,-500), Pawn.Location, true);
                          	if (mahDecal == none) {
                          		mahDecal = spawn(class'RTSSelectionDecal', self, ,groundLocation, Rotator(groundNormal*-1));
                          		class'DecalManager'.static.SetDecalParameters(mahDecal.Decal, SelectionDecal, groundLocation, Rotator(groundNormal * -1), 100, 100, 10, true, fRand() * 360, none, true, false, '', INDEX_NONE, INDEX_NONE, INDEX_NONE, class'Decalmanager'.default.DecalDepthBias, class'Decalmanager'.default.DecalBlendRange);
                          	} else {
                          		DecalRotation = mahDecal.Rotation;
                          		DecalRotation.Yaw += 6000*DeltaTime;
                          		mahDecal.SetLocation(groundLocation);
                          		mahDecal.SetRotation(DecalRotation);
                          	}
                          }
                          and:
                          Code:
                          function onDeselect() {
                          	mahDecal.Destroy();
                          	mahDecal = none;
                          	selected = false;
                          }
                          The class RTSSelectionDecal extends DecalActorMovable and has bNoDelete=FALSE in default properties

                          Comment

                          Working...
                          X