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"

How to rotate a character around an objects using keyboard inputs ?


I want my character to rotate around a "target" which is an other pawn but I have some difficulties. Indeed, when my character rotate around its target, the distance between these two increase more and more. The best I could do make an increase around 1 unit per second.

Here is a shema, where :

   P(n) and dir(n) is the position and direction of the character, 
   C is the position of the character's target
   P(n+1) and dir(n+1) is its (supposed) future position and (supposed) futur direction,
   d is the distance which will be (supposedly) traveled by the character,
   D is the distance between the character and its target.

alt text

Here is my blueprint which permit me to rotate the character around the target : "delta" is the half of the angle between [CP(n)] and [CP(n+1)].

alt text

I hope my blueprint doesn't confuse you (like "why delta is multiplied by 5.1?" well I don't know either why) but it's the one which is giving me the best results.

Could I have some advice to optimize my blueprint and about the way to rotate a pawn around an other please ?

Product Version: Not Selected
shema.png (42.7 kB)
rotation.png (317.4 kB)
more ▼

asked Oct 16 '14 at 02:31 PM in Blueprint Scripting

avatar image

1 1 2 2

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

2 answers: sort voted first

Why not place a target point in front of your follower and use a "Simple Move To Location" node?

more ▼

answered Oct 16 '14 at 03:44 PM

avatar image

2k 62 24 111

avatar image Eclion Oct 16 '14 at 04:50 PM

Hello alperenakyuz,

Thank you for your response, but, the problem is that when I (my character) rotate around the target (with the up-down input), I can also get closer to it (with the right-left input). With your solution, I will have less control on my character movements, especially when I will want to get closer to my target.

avatar image alperenakyuz Oct 16 '14 at 05:42 PM

Ok, I think I'm beginning to understand. You want your character to orbit the other pawn. Up/ Down would move your character along the orbit and right/left would decrease/increase the radius of that orbit. Is that it?

avatar image Eclion Oct 16 '14 at 07:10 PM

yes, it is :)

avatar image alperenakyuz Oct 16 '14 at 07:19 PM

Is there a specific reason for not just using an angle to determine where the player should be? You can just update your character's world location by multiplying the sine and cosine values of that angle with the desired radius.

avatar image Eclion Oct 16 '14 at 07:43 PM

It is because if I update the character's world location instead using the "add movement input" node, my character will not use the walking animation anymore. Am I wrong ?

avatar image alperenakyuz Oct 16 '14 at 07:51 PM

You can cheat though. Your animation blueprint uses pawn velocity to determine the blending weights. In order to replace this, you can get the difference between the current and previous locations of your character and divide it with the delta seconds to get your pseudo-speed. Use it to update the value in the animation blueprint as I do in the screenshot:alt text

pseudospeed.jpg (125.0 kB)
avatar image Eclion Oct 16 '14 at 08:00 PM

So, should I use the "set actor location and rotation" node with a little delta and set the blendSpace speed with the pseudoSpeed, so it may create the illusion of movement ? If I want a fluid animation, won't it be slow if I use the "InputAxis" node ?

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

Here is a working example:

alt text

orbit.png (281.4 kB)
more ▼

answered Oct 16 '14 at 08:24 PM

avatar image

2k 62 24 111

avatar image Eclion Oct 16 '14 at 09:00 PM

I understand how you get the speed and a little how you use it but what I don't is : what are you using for the character deplacement ? Because if you use the "set actor location" node, I am sure there will be conflict with my character moving closer to the target using the "add movement input" node. Can you enlighten me please ?

avatar image alperenakyuz Oct 16 '14 at 09:05 PM

I disconnected the "add movement input" node so it doesn't do anything.

avatar image Eclion Oct 16 '14 at 09:08 PM

Yes but in this case, how are you moving the character ?

avatar image alperenakyuz Oct 16 '14 at 09:09 PM

Sorry, I apparently forgot to upload the second screenshot!!! Here it is

alt text

magic.png (172.5 kB)
avatar image alperenakyuz Oct 16 '14 at 09:10 PM

Anchor is the pawn object your character orbits

avatar image Eclion Oct 16 '14 at 09:33 PM

Thanks a lot. I will try using your method and I will give you feedback later.

avatar image Eclion Oct 18 '14 at 01:51 PM

Hello again alperenakyuz.

I tried to use your blueprint, but I realized that with it, I can't jump forward. I think it's due to the character velocity, which is null when we use setActorLocation node instead of the AddMovementInput one.

So it may not be the right solution for my problem (well I never said before I could jump. sorry. ><) but thanks a lot for your point of view :)

avatar image alperenakyuz Oct 25 '14 at 01:47 PM

Are you still into this? I got some free time on my hands, might check how to achieve jumping.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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