How can I make my pawn move?
I have created my custom character in C++ and have it spawning in the world as the default thing that your character is possessing. It has my custom components attached, as in the code you read below you will see the debug lines show up so I do know they are there. When I hit 'W' 'A' 'S' or 'D' (I have them set as the axis input in the project settings) it will fire off my custom events shown in the code below. However, no movement is happening. I can't make it move no matter how hard I've tried for the past 7 hours, and scouring the net (long work day, maybe my brain is fried.) I've tried SetPhysicsLinearVelocity, AddImpulse, etc. The debug line directly after the movement code works just fine, just... no movement. Any suggestions?
If someone could shed some light on this, I'd really appreciate it. I personally prefer to do all my work through code and C++, so, learning the syntax and how things need to happen in their specific ways with UE4 is a little bit frustrating at times.
Thanks so much guys, and if there is any additional information you need, please just ask and I will provide anything and everything.
If you're using a character, do you not want to be using the movement component? Otherwise you could probably use a pawn and try applying physics velocity (note that your root component would need to be a primitive component with physics enabled to be pushed around by physics forces).
answered May 29 '14 at 04:26 AM
You need to attach a movement component. Try adding something like this to your constructor:
If you're still stumped, I suggest looking at the DefaultPawn.cpp and using it as a starting point for your custom pawn class. Its a very simple extension of Pawn.
answered May 30 '14 at 12:49 AM
OK, I found a solution that solved my issue. Not sure if it is the right one, but at least it works.
answered Jun 10 '14 at 03:19 PM
It looks like what you're doing should work.
It's possible that your player's actor is not the instance you're working on, so it doesn't appear to be moving, but another instance is actually moving?
Try something like:
NB. Also, try use very high values for forces and impluses (5000, not 100); if you use a low value, you usually can't see it in the editor due to friction, etc. on physics simulated objects.
Follow this question
Once you sign in you will be able to subscribe for any updates here