x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to push an object in the direction you are facing by clicking on it?

I would like to create a set up where clicking on an object in the world pushes that object slowly forward in the direction I am facing (this is using first person camera).

What is the best way to push an object by clicking on it?

Product Version: Not Selected
Tags:
more ▼

asked Feb 03 '15 at 11:17 PM in Blueprint Scripting

avatar image

markazama
1 1 2 1

avatar image Wallhalla Feb 04 '15 at 07:54 AM

hey there,

your playercontroller has a RotationMatrix stored (Get Control Rotation), from this you can create a ForwardVektor, which is the Direction your Center is pointing, i assume they are normalized so the length of this vector is 1.

Knowing this you can translate your object in adding this Vektor to your objects Transformation with a multiplier (how far shall this object moves). Result: your object moves to the direction you look at.

I believe there were a node (Add Movement or something).

kind regards Wallhalla

avatar image markazama Feb 04 '15 at 09:34 PM

Thanks for the input.

I had trouble with this, because I was trying to do this in the BP for the object I wanted to push. Should all this scripting be in the player object?

Also, which node do I need to use to convert the rotation output of Get Control Location into a vector for the Add Force at Location node.

I'm pretty new at this, so any fine detail would be much appreciated.

avatar image Wallhalla Feb 05 '15 at 08:06 AM

hey there,

well its up to you doing it in controller or your object you want to push.

First the Vector for the direction you want to push:

Get Control Rotation (target PlayerController or Pawn)-> Output -> Get Forward Vector -> Save: Now you have the push direction aka the vector you look along.

for the rest: I will do a picture for you when im home again, in an hour or so...

just wait ;)

avatar image Wallhalla Feb 05 '15 at 09:37 AM
avatar image markazama Feb 08 '15 at 09:08 PM

Thanks for this. I'll give it all a look and get back to you with how it went.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question