Moving an actor

Discussions about Coding and Scripting
ShaiHulud
Adept
Posts: 446
Joined: Sat Dec 22, 2012 6:37 am

Moving an actor

Post by ShaiHulud » Sun Jul 24, 2022 4:51 am

I have a custom actor that I want to move in response to the firing of a trigger (caused by a player touching a mover). I've been using SetLocation. But nothing happens (not quite true, in a Practice game it does work, but in a net game, nothing happens). I spent a great deal of time searching for information about this, but nothing that I came across provided the solution to what seemed as though it ought to be a very simple operation.

A chance comment on another UT forum (about an unrelated topic) prompted me to copy the defaultproperties from the pawn class to the defaultproperties list of my actor (of course, many of these are pawn class specific, so I pruned those properties immediately). Then I started a new dedicated server. And SetLocation worked. By a process of elimination, the key defaultproperty is:

Code: Select all

bIsPawn=True
When that's set to true, calling SetLocation for my actor updates its position visibly for connected clients. As pleased as I am about this, I'm also unhappy about my actor masquerading as pawn, because I've seen an awful lot of script that uses a "bIsPawn" test to figure out what kind of object it's dealing with. So, do I have any alternatives? This feels like one of those situations where I don't know what I don't know, so I'm struggling to see what my options are.

Here's a pared down/simplified version of the relevant part of my class (that I'm using to move the actor):

Code: Select all

event trigger(actor other, pawn eventInstigator)
{
  local mover MV;
  local myCustomActor MCA;
  local vector V;

  if (other.isA('mover'))
  {
    MV = mover(other);

    switch (MV.tag)
    {
      case 'mvMyMover':
        disable('trigger');

        foreach allActors(class'myCustomActor', MCA)
        {
          V = MCA.location;
          V.z = Z.z - 100;
          MCA.setLocation(V);

          ...
          enable('trigger');
          break;
        }
    }
The defaultproperties list for my custom actor (which is actually a reworking of the HeroStatue v110 class) looks like this (all taken unchanged from the HeroStatue class):

Code: Select all

  bStatic=false
  bNoDelete=true
  bAlwaysRelevant=true
  bAlwaysTick=true
  remoteRole=ROLE_SimulatedProxy
  drawType=DT_Mesh
  skin=Texture'HeroStatueEx.Skins.HeroSkin'
  mesh=LodMesh'Botpack.SelectionMale2'
  bCollideWhenPlacing=true
  collisionRadius=16.000000
  collisionHeight=32.000000

Buggie
Godlike
Posts: 1766
Joined: Sat Mar 21, 2020 5:32 am

Re: Moving an actor

Post by Buggie » Sun Jul 24, 2022 5:10 am

remoteRole=ROLE_SimulatedProxy
This mean location replicate from server only first time.
If you want constant replicatate loation you need ROLE_DumbProxy..

ShaiHulud
Adept
Posts: 446
Joined: Sat Dec 22, 2012 6:37 am

Re: Moving an actor

Post by ShaiHulud » Sun Jul 24, 2022 5:46 am

Thank you Buggie, very helpful, that did the trick.