For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

[solved] Attach Actor to Actor

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
LannFyre
OldUnreal Member
Posts: 157
Joined: Fri Mar 13, 2015 7:01 am

[solved] Attach Actor to Actor

Post by LannFyre »

I need to attach a directional actor to another directional actor.  SpriteActor (used for animations) needs to be attached to my custom playerpawn (RPG_LionPlatformer), facing the same direction and being in the same location as the playerpawn.  How can I do this?

If this is solved, I may have a new progress video coming out to show off sprites working properly.  I have a parser for sprites mostly working, animation and animation managers work properly, and I now need an actor (SpriteActor) that can be used in order to "play" animations on that isn't a playerpawn to avoid dealing with figuring out why animation code either isn't being called or works improperly in player state code.  I also have a sprite sheet that acts as a library for textures stored to be played sequentially.
Last edited by LannFyre on Thu Jun 29, 2017 1:40 am, edited 1 time in total.
i tryin'a be a gud boi
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Re: Attach Actor to Actor

Post by Bleeder91[NL] »

- Set the actor's Physics to PHYS_Trailer;
- Set the actor's owner to your Playerpawn;
- Set bTrailerSameRotation of the actor to True.
Last edited by Bleeder91[NL] on Fri Jun 02, 2017 4:35 pm, edited 1 time in total.
Image
User avatar
.:..:
OldUnreal Member
Posts: 1637
Joined: Tue Aug 16, 2005 4:35 am

Re: Attach Actor to Actor

Post by .:..: »

It depends, relative to what?

If same rotation and location as playerpawn, you can use PHYS_Trailer.

If same rotation but a location with an offset from playerpawn, then a script like this:

Code: Select all

function Tick( float Delta )
{
      SetLocation(Owner.Location + vect(0,0,10) + (vect(10,10,0) >> Owner.Rotation));
}
If a relative location and rotation:

Code: Select all

function Tick( float Delta )
{
      local Coords C;
      
      C = GetUnitCoords();
      C *= rot(16000,0,0);
      C *= Owner.Rotation;
      SetRotation(OrthoRotation(C.XAxis,C.YAxis,C.ZAxis));
      SetLocation(Owner.Location + vect(0,0,10) + (vect(10,10,0) >> Owner.Rotation));
}
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
User avatar
LannFyre
OldUnreal Member
Posts: 157
Joined: Fri Mar 13, 2015 7:01 am

Re: Attach Actor to Actor

Post by LannFyre »

How do I set an actor's owner? I've done the other two steps so far. Also here is a test video before I got your replies, I went with a setlocation() setrotation() setup through tick and found some... interesting things about sprites.

https://www.youtube.com/watch?v=__NECIJ ... e=youtu.be

An interesting side note is that sprites only have one polygon (from my understanding and reading) which is the only point affected by light sources, so your sprite could be sitting almost half in dark and half in light, and would only change to a darkened or brightened sprite based on where that poly is.
i tryin'a be a gud boi
User avatar
.:..:
OldUnreal Member
Posts: 1637
Joined: Tue Aug 16, 2005 4:35 am

Re: Attach Actor to Actor

Post by .:..: »

You can use Actor.SetOwner() or even better, use spawn owner parameter:
Spawn(class'MyActor',)
i.e from playerpawn: Spawn(class'MyActor',self);
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
User avatar
LannFyre
OldUnreal Member
Posts: 157
Joined: Fri Mar 13, 2015 7:01 am

[solved] Attach Actor to Actor

Post by LannFyre »

Here is what I went with:

Code: Select all

event PostBeginPlay()
{
      local bool bSActorFound;

      bSActorFound=false;
      if ( myActor == none ) {
            ForEach AllActors (class'xActor', myActor) {
                  if (myActor.Owner == none && myActor.AttachActor == none ) {
                        myActor.SetOwner(self);
                        myActor.AttachActor = self;
                        bSActorFound = true;
                        break;
                  }
            }
            if (bSActorFound == false) {
                  myActor= Spawn(class'myActor',self); // owner = self
                  myActor.AttachActor = self;
            }
      }
      
      super.PostBeginPlay();
}

Code: Select all

state Active
{
      event Tick( float DeltaTime )
      {
            SetRotation( AttachActor.Rotation );
            [...]
      }
}
i tryin'a be a gud boi

Return to “UScript Board”