# How would you get an input, and make it affect something?

**URL:** <https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 16, 2019, 2:12am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338 "2019-07-16T02:12:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Bonk\_Batter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@The\_Bonk\_Batter](https://forums.unrealengine.com/u/The_Bonk_Batter)\
**Post date:** [July 16, 2019, 2:12am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/1 "2019-07-16T02:12:12Z")

</div>

Hello! I’m currently in the early stages of learning C++, and I have got something to move on a constant loop. What i was wondering, was if you could press a button, and the loop could, for example, speed up. This would help me out in the long run, so I’d appreciate an answer 🙂

---

<div class="post-metadata">

**Author:** ![pneuma](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pneuma/32/983845_2.png) [@pneuma](https://forums.unrealengine.com/u/pneuma)\
**Post date:** [July 16, 2019, 6:46am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/2 "2019-07-16T06:46:13Z")

</div>

How do you control the speed of your constant loop right now? You can change it by clicking a button or something after adding some input actions in your project settings.

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/d/c/ddcd52e6b7da44aaf3949f64e4efbbc4a6efd63d.png)

After that you can use virtual function `SetupPlayerInputComponent` to bind specific function in your code to specific button in your keyboard.

In the following tutorial you can see a step-by-step guide how to add `WASD` movement in a project.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![The\_Bonk\_Batter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@The\_Bonk\_Batter](https://forums.unrealengine.com/u/The_Bonk_Batter)\
**Post date:** [July 17, 2019, 6:03am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/3 "2019-07-17T06:03:20Z")

</div>

![282614-crud.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/7/c173d6c8b21d27d24c4c761dfca82839485c1b04.png)

Well, this is where i got to, a failed compile. Is it because I have the setupplayerinput component twice, and should i put it in private or public? Another question is the input functions section. There doesn’t seem to be any reference to growing in the script besides here, so maybe i followed the tutorial wrong?

Thank you for answering a rush of questions from a newbie programmer 🙂

---

<div class="post-metadata">

**Author:** ![pneuma](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pneuma/32/983845_2.png) [@pneuma](https://forums.unrealengine.com/u/pneuma)\
**Post date:** [July 17, 2019, 7:04am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/4 "2019-07-17T07:04:34Z")

</div>

`protected` section has to be **inside** the class definition. In your case it’s outside and that’s why it’s not compiling. Also you **cannot** have the same method declaration twice so do not add `SetupPlayerInputComponent` twice, one is enough. 🙂

 ![282616-protected.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/0/2/00227fc6c62aade6a19bf216ac906d5ba4d5b6d5.png)

---

<div class="post-metadata">

**Author:** ![The\_Bonk\_Batter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@The\_Bonk\_Batter](https://forums.unrealengine.com/u/The_Bonk_Batter)\
**Post date:** [July 19, 2019, 5:14am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/5 "2019-07-19T05:14:09Z")

</div>

![282793-compile.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/d/d/8dd1d84cb79af2bc512e7cd6a35acadef2021630.png)

Well, I did something write, but now theres a new problem with the Amypawn. Would i just change this to the name of my actor? Besides that, The build log says I require permission for something, what would this be for?

Thank you for the continued help!

---

<div class="post-metadata">

**Author:** ![pneuma](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pneuma/32/983845_2.png) [@pneuma](https://forums.unrealengine.com/u/pneuma)\
**Post date:** [July 19, 2019, 6:04am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/6 "2019-07-19T06:04:41Z")

</div>

Try `AMyPawn : public APawn` rather than `AMyPawn ; public APawn`.

---

<div class="post-metadata">

**Author:** ![The\_Bonk\_Batter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@The\_Bonk\_Batter](https://forums.unrealengine.com/u/The_Bonk_Batter)\
**Post date:** [July 20, 2019, 5:35am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/7 "2019-07-20T05:35:08Z")

</div>

![282867-syntax.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/6/e/d6e481bed488b58c64ac9a3c241683f4b419265f.png)

Okay, that worked! Now all thats left is a syntax error with {} brackets on the class!  
Thank you so much for all the help 🙂

---

<div class="post-metadata">

**Author:** ![pneuma](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pneuma/32/983845_2.png) [@pneuma](https://forums.unrealengine.com/u/pneuma)\
**Post date:** [July 20, 2019, 8:42am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/8 "2019-07-20T08:42:45Z")

</div>

You cannot use semicolon after `public APawn` because you have just told the compiler that you are going to define your own class called `AMyPawn` so you cannot stop there.

Try the following:

```
UCLASS()
class UNREALCPP_API AMyPawn : public APawn
{
    GENERATED_BODY()

  public:
    // rest of your code goes here
    // ...
    virtual void BeginPlay() override;
};
```

---

<div class="post-metadata">

**Author:** ![The\_Bonk\_Batter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@The\_Bonk\_Batter](https://forums.unrealengine.com/u/The_Bonk_Batter)\
**Post date:** [July 21, 2019, 2:24am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/9 "2019-07-21T02:24:19Z")

</div>

Oh, okay! That worked! Thank you 🙂  
So i guess you cant use an empty class as the engine will not know what to do with it?

---

<div class="post-metadata">

**Author:** ![The\_Bonk\_Batter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@The\_Bonk\_Batter](https://forums.unrealengine.com/u/The_Bonk_Batter)\
**Post date:** [July 21, 2019, 5:11am UTC](https://forums.unrealengine.com/t/how-would-you-get-an-input-and-make-it-affect-something/452338/10 "2019-07-21T05:11:52Z")

</div>

Okay, for some reason my ue4 is 4.22.3 now, and my old project was just 4.22, and now its not compiling. And when I tried to compile from the source, I got errors as it would not use the unreal terms in it, so I can’t open my work anymore. Do you know why this would occur?
