[Mono-ue] Fixed get-started code

Johannes Jüngst johannesjuengst at gmail.com
Sat Nov 1 20:44:46 UTC 2014


Hey guys,

if you have problems using the category-property try this. I fixed the
get-started code. It should work fine now.

Regards, Johannes

 


using System;
using UnrealEngine.Runtime;
using UnrealEngine.Engine;


namespace MonoProject1Mono
{
    public class RotatorTest : Actor
    {
        [UProperty][EditorVisible][Category("Test")]
        public Subobject<StaticMeshComponent> MeshComponent { get; set; }

        [UProperty][EditorVisible][Category("Test")]
        public float RotationRate { get; set; }

        [UProperty][EditorVisible][Category("Test")]
        public bool RotateClockwise { get; set; }

        [UProperty][EditorVisible][Category("Test")]
        public float Velocity { get; set; }

        // Constructor called when creating or loading an object
        protected RotatorTest(PostConstructInitializeProperties pcip)
            : base(pcip)
        {
            MeshComponent =
pcip.CreateDefaultSubobject<StaticMeshComponent>("StaticMeshComponent0");
            SetRootComponent(MeshComponent);

            RotateClockwise = true;
            RotationRate = 20.0f;
        }

        // Constructor for hot-reloading. UProperties will already be
initialized, but any purely managed fields or data
        // will need to be set up
        protected RotatorTest(IntPtr nativeObject)
            : base(nativeObject)
        {

        }

        protected override void ReceiveTick(float DeltaSeconds)
        {
            float yawDelta = RotationRate * DeltaSeconds;
            if (!RotateClockwise)
                yawDelta *= -1;

            Rotator rotation = GetActorRotation();
            rotation.Yaw += yawDelta;

            OpenTK.Vector3 forwardVec = GetActorForwardVector();
            OpenTK.Vector3 location = GetActorLocation();
            location += DeltaSeconds * Velocity * forwardVec;

            SetActorLocationAndRotation(location, rotation, true);

        }
    }
}

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-ue/attachments/20141101/9bc56180/attachment-0001.html>


More information about the Mono-ue mailing list