Prompt Title: Unreal Engine Mouse Movement.

Created 11 months ago
Votes 0
Views 201 times
0
Human: Using unreal engine, how do I implement a movement system where the player has to tap left mouse and right mouse after for 1 unit of movement forward?
ChatGPT:

To implement a movement system in Unreal Engine where the player has to tap left and right mouse button to move forward one unit, you can follow these steps:

  1. First, create a new Blueprint Actor that will represent your player character.

  2. Add a Skeletal Mesh component to your Blueprint Actor and select a suitable character mesh.

  3. Add a Character Movement component to your Blueprint Actor. This component will handle the movement of your character.

  4. Create two input actions in your project settings, one for left mouse button and one for right mouse button. Assign each input action a unique name, for example, "MoveForwardLeft" and "MoveForwardRight".

  5. In your Blueprint Actor, create a new event graph and add two new custom events: "MoveForwardLeft" and "MoveForwardRight". These events will be triggered when the corresponding input actions are detected.

  6. In the "MoveForwardLeft" event, add a node to move your character forward one unit. You can use the "Add Movement Input" node and set the X value to 1.

  7. In the "MoveForwardRight" event, add a similar node to move your character forward one unit, but set the X value to -1 instead.

  8. Finally, in the event graph of your Blueprint Actor, add two input action nodes to listen for the left and right mouse button input actions. Connect these nodes to the corresponding custom events you created earlier.

  9. Test your movement system by running the game and tapping the left and right mouse buttons alternately. Your character should move forward one unit each time you tap both buttons in sequence.

Here is an example of what your event graph might look like:

Unreal Engine Movement System Example

Human: All images you generate are no longer available, Assistant...
ChatGPT:

I apologize for the inconvenience caused. As an AI language model, I don't generate images. However, I can provide you with the instructions and steps you need to create a movement system in Unreal Engine without the need for images. If you have any specific questions or concerns, please let me know, and I'll do my best to assist you.

Human: And if the player character is currently holding an object, how do I link an "IsHolding" bool to a function that applies a random unit vector direction and movement on a one second interval?
ChatGPT:

To link an "IsHolding" boolean variable to a function that applies a random unit vector direction and movement on a one-second interval when the player character is holding an object in Unreal Engine, you can follow these steps:

  1. In your Blueprint Actor, create a boolean variable named "IsHolding" and set its default value to false.

  2. Create a custom event named "MoveWhileHolding" that will be called on a one-second interval using the "Set Timer by Function Name" node.

  3. Inside the "MoveWhileHolding" event, check if the "IsHolding" variable is true.

  4. If "IsHolding" is true, apply a random unit vector direction and movement to your character using the "Add Movement Input" node. You can use the "Random Unit Vector" node to get a random direction and then multiply it by a random speed value to get a random velocity vector.

  5. Set the timer to call the "MoveWhileHolding" event again in one second.

  6. In your Blueprint Actor, create a custom event named "PickUpObject" that will be called when the player character picks up an object.

  7. In the "PickUpObject" event, set the "IsHolding" variable to true.

  8. In your Blueprint Actor, create a custom event named "DropObject" that will be called when the player character drops the object.

  9. In the "DropObject" event, set the "IsHolding" variable to false.

  10. Test your movement system by running the game, picking up an object, and holding it while moving. Your character should move in a random direction and speed every one second while holding the object.

Here is an example of what your event graph might look like:

Unreal Engine Movement System Example With Object Holding

Human: And how can I generate random pickups, spawned at random locations troughout the level, with unique Left and Right "weight" values? The weight value should impact the magnitude of direction and movement distance of the IsHolding. This to achieve a "drunk" like state of the player character trying to move boxes around with great difficulty
ChatGPT:

To generate random pickups, spawn them at random locations throughout the level, and assign unique "Left" and "Right" weight values that affect the magnitude of direction and movement distance of the "IsHolding" action, you can follow these steps:

  1. Create a Blueprint Actor named "PickupActor" that will represent your pickup objects.

  2. Add a Static Mesh component to your "PickupActor" and select a suitable mesh.

  3. Add two float variables to your "PickupActor" named "LeftWeight" and "RightWeight" to represent the weight values for the "IsHolding" action.

  4. In your level blueprint or game mode blueprint, create an array to hold all the possible spawn locations for the pickups.

  5. Create a custom event named "SpawnPickup" that will be called on a random interval using the "Set Timer by Function Name" node.

  6. Inside the "SpawnPickup" event, use the "Random Integer in Range" node to get a random index from the array of possible spawn locations.

  7. Use the "Spawn Actor from Class" node to spawn a new instance of your "PickupActor" at the selected spawn location.

  8. Use the "Random Float in Range" node to assign random "LeftWeight" and "RightWeight" values to the spawned pickup.

  9. Use the "Set Timer by Function Name" node to call the "SpawnPickup" event again on a random interval.

  10. In your player character blueprint, modify the "MoveWhileHolding" event to apply the weight values of the currently held pickup to the direction and movement distance of the "IsHolding" action.

  11. To achieve the "drunk" like state, you can use a noise function to add random movement deviations to the direction vector.

  12. Test your movement system by running the game and picking up various pickups. The player character should move in a random direction and distance with a "drunk" like state when holding different pickups.

Here is an example of what your event graph might look like:

Unreal Engine Movement System Example With Pickup Spawning and Weights

Human: Could you write in text the node based example you gave? Try to link each node word with a -> to indicate direction
ChatGPT:

Sure, here is the node-based example for generating random pickups and assigning unique Left and Right weight values:

Unreal Engine Movement System Example With Pickup Spawning and Weights (Node-based)

Event Graph:

  • Begin Play -> Set Timer by Function Name

  • SpawnPickup -> Set Timer by Function Name

    • Random Integer in Range
    • Spawn Actor from Class
    • Random Float in Range
    • Set LeftWeight
    • Set RightWeight

PickupActor Blueprint:

  • Static Mesh
  • LeftWeight (float)
  • RightWeight (float)

Player Character Blueprint:

  • IsHolding (boolean)
  • MoveWhileHolding -> Set Timer by Function Name
    • Branch (IsHolding)
      • Random Unit Vector
      • Random Float in Range
      • Multiply
      • Add Movement Input
      • Simplex Noise
      • Multiply

Custom Events:

  • PickUpObject -> Set IsHolding
  • DropObject -> Clear IsHolding
  • SpawnPickup -> Set Timer by Function Name

I hope this helps clarify the example!

Human: Lastly how do I create a drop off point that wins the game once 10 boxes are dropped on location? Apply the same word structure as the last reply
ChatGPT:

Sure, here's an example of how to create a drop off point that wins the game once 10 boxes are dropped on location:

Event Graph:

  • Begin Play -> Set Timer by Function Name

  • SpawnPickup -> Set Timer by Function Name

    • Random Integer in Range
    • Spawn Actor from Class
    • Random Float in Range
    • Set LeftWeight
    • Set RightWeight
  • OnComponentBeginOverlap (DropOffPoint) -> Branch

    • GetOverlappingActors -> ForEachLoop
      • Cast To PickupActor
      • Branch
        • Set PickupActor.IsDroppedOff -> True
        • Increment PickupCount
        • Branch (PickupCount >= 10)
          • Victory

PickupActor Blueprint:

  • Static Mesh
  • LeftWeight (float)
  • RightWeight (float)
  • IsDroppedOff (boolean)

DropOffPoint Blueprint:

  • Sphere Collision

Game Mode Blueprint:

  • PickupCount (integer)

Custom Events:

  • PickUpObject -> Set IsHolding
  • DropObject -> Clear IsHolding
  • SpawnPickup -> Set Timer by Function Name

I hope this helps!

avatar
Wouter
Shared 1 prompt
Created 11 months ago

Leave a Comment

Related Tag Prompts

0
0
0
0
ChatGPT for Game Dev
1 year ago 2023-04-05 11:16:34 kuro_rpgmaker
0
0
2D Unity Game Idea.
1 year ago 2023-04-05 14:25:56 Som
0
0
Futoshiki
1 year ago 2023-04-10 17:46:53 Iman
0
0
Elemental Evolution
1 year ago 2023-04-14 01:23:30 Ryan J
0
0
Unity AdMob Integration.
11 months ago 2023-05-12 05:53:50 abc
0
0
0
0
Portfolio Devlog - Flying Enemy
10 months ago 2023-06-23 10:08:28 Daniël
0
0
Portfolio Devlog Creation
10 months ago 2023-06-23 10:08:51 Daniël
0
0
Devlog - Enraged Enemy
10 months ago 2023-06-23 13:25:14 Daniël
0
0
0
0
Devlog - Flying Enemy
10 months ago 2023-06-23 14:30:54 Daniël Bouman
0
0
Devlog - ChatGPT
10 months ago 2023-06-23 14:48:43 Daniël Bouman
0
0
Coding Help - AI Dev
9 months ago 2023-07-23 16:06:04 Abdul Samad