Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Yet another "accessing a variable in a different class" post

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

  • Yet another "accessing a variable in a different class" post

    Alright, I know there are other posts out there but I can't figure out how to implement their examples to solve my problem, as I'm having a very hard time understanding the syntax.

    I am working on a camera that can seamlessly transition from first- to third person view (and back of course), and need to hide and unhide my skeletal mesh accordingly (hidden in first person, shown in third person).

    I have the camera code doing it's thing - not perfectly, but it works, but hiding and unhiding the mesh is proving a problem.

    The thing is, I'm doing this from my PlayerController class as I am patching the code together from several different camera examples, and I just can't figure out how to access and change bOwnerNoSee in the Pawn class.

    I've tried

    Code:
    function HideMesh(boolean meshVisible)
    {
        local MyPawn PawnMesh;
        PawnMesh = MyPawn(Owner);
        PawnMesh.Mesh.SetOwnerNoSee(meshVisible);
    }
    Now, Mesh is just a reference to my skeletal mesh object as defined in the pawn class, and I've seen the SetOwnerNoSee(boolean) demonstrated and working in another example.

    The code will compile, but absolutely will not work so I'm clearly doing it wrong. What do I need to change to make it right, and how?

  • #2
    Pawn doesn't own it's Controller, Controller owns it's Pawn. What you want is:

    Pawn.Mesh.SetOwnerNoSee()

    Comment


    • #3
      Ok, let me see if I understand this then.. Pawn is owned by PlayerController. Since my default pawn class is set to MyPawn, Pawn actually is accessing MyPawn.uc?

      Oh, and it works now by the way. Just some polishing to get the camera transitioning smoothly and I'll have exactly what I was looking for.

      Comment


      • #4
        no, Pawn is a variable of type Pawn, that is defined in Controller. It holds the instance of a Pawn that this Controller is controlling.

        Controller.uc:

        var Pawn Pawn;

        ... then somewhere in the Possess() function, it sets Pawn = PawnBeingPossessed.

        No matter what kind of Pawn it is, you can always access anything declared in Pawn (or it's superclasses, Actor and Object), for the instance that is being controlled, by accessing Pawn.whatever

        You only need to cast that to MyPawn(Pawn) if you need to access something htat is specifically declared in MyPawn

        Comment


        • #5
          Oh, I see. The fog is clearing slightly now.

          So... if I wanted to change, say, GroundSpeed I'd do Pawn.GroundSpeed = x, but if I defined my own function DoStuff(some argument) in MyPawn I would have to.. erm..

          Code:
          var MyPawn DoStuffPawn;
          DoStuffPawn.DoStuff(blah);
          is that correct?

          Comment


          • #6
            MyPawn(Pawn).DoStuff(blah);

            Comment


            • #7
              to put it simply both the controller and the pawn have a reference to eachother called pawn and controller respectively. Personally I think it is confusing calling your pawn reference pawn, but a lot of things don't make sense to me in unreal :P

              Comment


              • #8
                Oh well, it's clear I have a long way to go before I start understanding UnrealScript. Still.. where there was darkness there is now a faint flicker of light.

                Comment

                Working...
                X