I’m trying to push a box in the direction my player is facing (x or y ) for a certain distance everytime the player click a key. How would I be able to do this? Any help is appreciated thanks
There are a few ways, we’d have to know few things first, is it just x or y? Like on a grid type movement? Or at an angle/diagonal as well? Are you wanting a precise amount of movement? Or just to be pushed in that direction a few feet or so?
(post deleted by author)
Cheers!
P.S. Don’t forget to set Auto Receive Input = Player 0
in the Class Defaults or the InputAction won’t fire.
(post deleted by author)
What is the purpose - is this a character with animation pushing a box, or is it just a programmatic need?
Then - does the box need to react to physics or is it just being pushed across space (and time tardis style, if so is it bigger on the inside) ?
What you need vastly dictates how you handle it.
A character with an animation for pushing can be made with a root motion animation so that the amount you push is directly controlled by the animation itself. This makes you able to break off from the push to a “pointless push" animatiom when you disable moment somehow (probably based on collision detection).
Moving anything via code on an axis is pretty trivial on the other hand. Just get the forward vector, add to it over a timeline component that drives how long and how far you want it to be pushed. You do still need to detect and disable this if you intend to react to collisions, so build with that in mind…