Skip to main content
edited tags
Link
Vaillancourt
  • 16.4k
  • 17
  • 56
  • 61
deleted 92 characters in body; deleted 7 characters in body
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101

I am coming from the Unity Engine, and trying to get my feet wet with Unreal Engine 4.8.x. I want to add a one-time force to an object. To accomplish this in Unity 5, I would use:

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

Explanation:

GetComponent<Rigidbody>() retrieves the Rigidbody Component. The Rigidbody is either alreadyalready attached to the GameObject, or this script has [RequiresComponent(typeof(Rigidbody))] above the class declaration. The AddForce method is called on the Rigidbody, and applies the force of a Vector3. The parameters of the Vector3 indicate the force on each axis which is applied. In the example above, the GameObject would move forward on its z-axis.

How would I accomplish this same thing in Unreal Engine 4? I would appreciate if you can elaborate on what exactly is happening in the code as well. I currently have an empty AActor script, and I am struggling to find out what to put in my BeginPlay() method.

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

As CobaltHex pointed out, UPrimitiveComponent has a UPrimitiveComponent.AddForce(FVector, BoneName) method. However, I cannot figure out how to use it. The real objective of this question is as a basic introduction to programming with Unreal Engine. I chose AddForce, because it is an extremely commonly used method with a visible effect (in Unity). All of the existing tutorials are either with an older version of unreal (which has different scripting) or are using blueprints (which has no scripting). That is why I am trying to figure out what the actual code would be and what that code does.

Specifically, I am looking for an answer which tells me what code is missing from my Unreal Engine script, and what that code does, similiarly as is presented with my Unity Engine example.

I am coming from the Unity Engine, and trying to get my feet wet with Unreal Engine 4.8.x. I want to add a one-time force to an object. To accomplish this in Unity 5, I would use:

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

Explanation:

GetComponent<Rigidbody>() retrieves the Rigidbody Component. The Rigidbody is either already attached to the GameObject, or this script has [RequiresComponent(typeof(Rigidbody))] above the class declaration. The AddForce method is called on the Rigidbody, and applies the force of a Vector3. The parameters of the Vector3 indicate the force on each axis which is applied. In the example above, the GameObject would move forward on its z-axis.

How would I accomplish this same thing in Unreal Engine 4? I would appreciate if you can elaborate on what exactly is happening in the code as well. I currently have an empty AActor script, and I am struggling to find out what to put in my BeginPlay() method.

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

As CobaltHex pointed out, UPrimitiveComponent has a UPrimitiveComponent.AddForce(FVector, BoneName) method. However, I cannot figure out how to use it. The real objective of this question is as a basic introduction to programming with Unreal Engine. I chose AddForce, because it is an extremely commonly used method with a visible effect (in Unity). All of the existing tutorials are either with an older version of unreal (which has different scripting) or are using blueprints (which has no scripting). That is why I am trying to figure out what the actual code would be and what that code does.

Specifically, I am looking for an answer which tells me what code is missing from my Unreal Engine script, and what that code does, similiarly as is presented with my Unity Engine example.

I am coming from the Unity Engine, and trying to get my feet wet with Unreal Engine 4.8.x. I want to add a one-time force to an object. To accomplish this in Unity 5, I would use:

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

Explanation:

GetComponent<Rigidbody>() retrieves the Rigidbody Component. The Rigidbody is already attached to the GameObject. The AddForce method is called on the Rigidbody, and applies the force of a Vector3. The parameters of the Vector3 indicate the force on each axis which is applied. In the example above, the GameObject would move forward on its z-axis.

How would I accomplish this same thing in Unreal Engine 4? I would appreciate if you can elaborate on what exactly is happening in the code as well. I currently have an empty AActor script, and I am struggling to find out what to put in my BeginPlay() method.

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

As CobaltHex pointed out, UPrimitiveComponent has a UPrimitiveComponent.AddForce(FVector, BoneName) method. However, I cannot figure out how to use it. The real objective of this question is as a basic introduction to programming with Unreal Engine. I chose AddForce, because it is an extremely commonly used method with a visible effect (in Unity). All of the existing tutorials are either with an older version of unreal (which has different scripting) or are using blueprints (which has no scripting). That is why I am trying to figure out what the actual code would be and what that code does.

Specifically, I am looking for an answer which tells me what code is missing from my Unreal Engine script, and what that code does, similiarly as is presented with my Unity Engine example.

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackGameDev/status/734404439826649089
Bumped by Community user
added 4 characters in body
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101

I am coming from the Unity Engine, and trying to get my feet wet with Unreal Engine 4.8.x. I want to add a one-time force to an object. To accomplish this in Unity 5, I would use:

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

Explanation:

GetComponent<Rigidbody>() retrieves the Rigidbody Component. The Rigidbody is either already attached to the GameObject, or this script has [RequiresComponent(typeof(Rigidbody))] above the class declaration. The AddForce method is called on the Rigidbody, and applies the force of a Vector3. The parameters of the Vector3 indicate the force on each axis which is applied. In the example above, the GameObject would move forward on its z-axis.

How would I accomplish this same thing in Unreal Engine 4? I would appreciate if you can elaborate on what exactly is happening in the code as well. I currently have an empty AActor script, and I am struggling to find out what to put in my BeginPlay() method.

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

As CobaltHex pointed out, UPrimitiveComponent has a UPrimitiveComponent.AddForce(FVector, BoneName) method. However, I cannot figure out how to use it. The real objective of this question is as a basic introduction to programming with Unreal Engine. I chose AddForce, because it is an extremely commonly used method with a visible effect (in Unity). All of the existing tutorials are either with an older version of unreal (which has different scripting) or are using blueprints (which has no scripting). That is why I am trying to figure out what the actual code would be and what that code does.

Specifically, I am looking for an answer which tells me what code is missing from my Unreal Engine script, and what that code does, similiarly as is presented with my Unity Engine example.

I am coming from the Unity Engine, and trying to get my feet wet with Unreal Engine 4. I want to add a one-time force to an object. To accomplish this in Unity 5, I would use:

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

Explanation:

GetComponent<Rigidbody>() retrieves the Rigidbody Component. The Rigidbody is either already attached to the GameObject, or this script has [RequiresComponent(typeof(Rigidbody))] above the class declaration. The AddForce method is called on the Rigidbody, and applies the force of a Vector3. The parameters of the Vector3 indicate the force on each axis which is applied. In the example above, the GameObject would move forward on its z-axis.

How would I accomplish this same thing in Unreal Engine 4? I would appreciate if you can elaborate on what exactly is happening in the code as well. I currently have an empty AActor script, and I am struggling to find out what to put in my BeginPlay() method.

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

As CobaltHex pointed out, UPrimitiveComponent has a UPrimitiveComponent.AddForce(FVector, BoneName) method. However, I cannot figure out how to use it. The real objective of this question is as a basic introduction to programming with Unreal Engine. I chose AddForce, because it is an extremely commonly used method with a visible effect (in Unity). All of the existing tutorials are either with an older version of unreal (which has different scripting) or are using blueprints (which has no scripting). That is why I am trying to figure out what the actual code would be and what that code does.

Specifically, I am looking for an answer which tells me what code is missing from my Unreal Engine script, and what that code does, similiarly as is presented with my Unity Engine example.

I am coming from the Unity Engine, and trying to get my feet wet with Unreal Engine 4.8.x. I want to add a one-time force to an object. To accomplish this in Unity 5, I would use:

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

Explanation:

GetComponent<Rigidbody>() retrieves the Rigidbody Component. The Rigidbody is either already attached to the GameObject, or this script has [RequiresComponent(typeof(Rigidbody))] above the class declaration. The AddForce method is called on the Rigidbody, and applies the force of a Vector3. The parameters of the Vector3 indicate the force on each axis which is applied. In the example above, the GameObject would move forward on its z-axis.

How would I accomplish this same thing in Unreal Engine 4? I would appreciate if you can elaborate on what exactly is happening in the code as well. I currently have an empty AActor script, and I am struggling to find out what to put in my BeginPlay() method.

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

As CobaltHex pointed out, UPrimitiveComponent has a UPrimitiveComponent.AddForce(FVector, BoneName) method. However, I cannot figure out how to use it. The real objective of this question is as a basic introduction to programming with Unreal Engine. I chose AddForce, because it is an extremely commonly used method with a visible effect (in Unity). All of the existing tutorials are either with an older version of unreal (which has different scripting) or are using blueprints (which has no scripting). That is why I am trying to figure out what the actual code would be and what that code does.

Specifically, I am looking for an answer which tells me what code is missing from my Unreal Engine script, and what that code does, similiarly as is presented with my Unity Engine example.

Notice removed Improve details by CommunityBot
Bounty Ended with no winning answer by CommunityBot
added 12 characters in body
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101
Loading
Notice added Improve details by Evorlor
Bounty Started worth 50 reputation by Evorlor
added 557 characters in body
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101
Loading
deleted 1 character in body
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101
Loading
added 647 characters in body
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101
Loading
added 6 characters in body
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101
Loading
edited body; edited title
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101
Loading
edited tags
Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101
Loading
Source Link
Evorlor
  • 5.9k
  • 9
  • 59
  • 101
Loading