[ad_1]

I’m coming from the Unity Engine, and attempting to get my toes moist with Unreal Engine 4.8.x. I need to add a one-time drive to an object. To perform this in Unity 5, I’d use:

void Begin(){
    GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 5));
}

Clarification:

GetComponent<Rigidbody>() retrieves the Rigidbody Element. The Rigidbody is
already hooked up to the GameObject.
The AddForce methodology is named on the Rigidbody, and applies the drive of
a Vector3. The parameters of the Vector3 point out the drive on every
axis which is utilized. Within the instance above, the GameObject would
transfer ahead on its z-axis.

How would I accomplish this identical factor in Unreal Engine 4? I’d recognize when you can elaborate on what precisely is going on within the code as effectively. I at the moment have an empty AActor script, and I’m struggling to search out out what to place in my BeginPlay() methodology.

void AMyActor::BeginPlay()
{
    Tremendous::BeginPlay();
    //What goes right here?  Why?
}

As CobaltHex identified, UPrimitiveComponent has a UPrimitiveComponent.AddForce(FVector, BoneName) methodology. Nevertheless, I can not determine tips on how to use it. The true goal of this query is as a fundamental introduction to programming with Unreal Engine. I selected AddForce, as a result of it’s a particularly generally used methodology with a visual impact (in Unity). All the current tutorials are both with an older model of unreal (which has totally different scripting) or are utilizing blueprints (which has no scripting). That’s the reason I’m attempting to determine what the precise code could be and what that code does.

Particularly, I’m in search of a solution which tells me what code is lacking from my Unreal Engine script, and what that code does, similiarly as is introduced with my Unity Engine instance.

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *