Announcement

Collapse
No announcement yet.

Yet another RInterpTo camera thread with a bonus CAPS LOCK query...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Yet another RInterpTo camera thread with a bonus CAPS LOCK query...

    I've looked around and seen solutions to this problem, but for some reason I just can't get it to work... Here's the basic gist:

    I have my controls for a third person type setup in my playercontroller class. Everything works just fine so far. I've created a system whereby holding down right mouse button instantiates "free look mode" (moving the mouse rotates the camera around the player character to look around) and holding down both left and right mouse buttons will instantiate "move mode" whereby dragging the mouse left and right will rotate the player as it continues to move forward with the camera lagging behind. All sweet. What I need now, and it has been killing me for about two days is to be able to transitionally reset the camera behind the player character with the press of a button (for clarity, the camera is on a spring arm in the playercharacter class).

    I can get it to instantaneously snap into position with this simple setup:

    Click image for larger version

Name:	snap.png
Views:	1
Size:	101.6 KB
ID:	1175034

    But as soon as I try and add a RinterpTo type setup I'm running into dramas. The below:

    Click image for larger version

Name:	partial snap.png
Views:	1
Size:	174.3 KB
ID:	1175035

    Incrementally snaps in decreasing intervals towards the eventual destination rather than one single interpolating movement. In other words, if I rotate the camera a long way from behind my character and press the middle mouse button the camera will snap to a location a large percentage of the overall required travel distance instantaneously. Press the button a second time and it will travel less. Keep repeatedly pressing and by the time the camera is here it needs to be it is moving in fractions.

    Edit to add: The Turn Rate Variable is 10. I've mucked about with this number, but it doesn't seem to make much difference. Certainly doesn't look like the cause of the issue.

    All of this makes me think that I need some sort loop to check if the camera is where it needs to be, else keep going type setup (I don't want to have to hold down the button to get there, single click and transition is the aim), but I haven't been able to get that to work either. Help me Obi Wan Kenobi's, you're my only hope

    The other question I have: Is there anyway to check on the status of the caps lock key? It seems odd that the only persistent state key we have can seemingly be only accessed as a key stroke. I've tried Is Input Key Down but that's still a check on the physical state of the Caps Lock rather than whether it is on or off. For an example, if I want Caps Lock off = walk mode; Caps Lock on = Run mode, is there any way to do it?

    Cheers in advance.

    #2
    Youre feeding it a bad delta time. The way i understand this, you need to hook up the RInterpTo to a continous outpu (such as a timelime or a tick event). The function only runs once if its hooked to an event that fires just once (rather than continously).

    Each call of the function (or more acurately - Macro) eases in the object's rotation from origin to target by rotating it by an amount based on time elapsed (Delta time) multiplied by the rate of rotation (Interp Speed).

    You have to think of programming in unreal as the software exists in slices of time called "frames" (as in frames per second or FPS). It runs all the appropriate code in the time between frames and provides an updated picture of the game state once each frame is fully "processed". Delta time (or delta seconds) is how much time the computer took to fully render that frame. It allows us to normalize client experience by converting frames into unit time since each computer will take varying amounts of time to finish rendering a given frame.
    Last edited by 6ixpool; 02-26-2016, 06:30 AM.
    Need another dev on your UE4 project? Send me a shoutout and I'll lend a hand

    Comment


      #3
      Store that capsule rotation in some variable on that middle button event.

      Then on event tick (you have there proper delta time) do interpot part.

      But instead of all that calculations try camera arm with decent LAG enabled, and set that rotation directly to camera arm. (maybe setting control rotation directly will also work).
      For just smoothing camera rotation you do not need interpto, camera arm with lag enabled is enough in almost all cases.

      Comment


        #4
        Thanks 6ixpool and Nawrot, I think I've almost got this...

        I've added a timeline as per the below image:
        Click image for larger version

Name:	2.PNG
Views:	1
Size:	118.4 KB
ID:	1101439

        but now I'm having "rubber banding" type issue. The camera rotates to the correct position smoothly as it should, but for about five or six seconds after the rotation, every time I rotate the camera it rotates back behind the mesh. I'm guessing I need to somehow stop the timeline once complete, but can't figure out how. I've tried a few different options such as breaking out the two comparative rotations with break rots and then comparing floats and feeding that into the stop exec on the timeline but to no avail...
        Attached Files

        Comment


          #5
          You need to store the original camera rotation in a variable and use the current rotation and interp back with a similar setup.
          Need another dev on your UE4 project? Send me a shoutout and I'll lend a hand

          Comment


            #6
            Originally posted by Scattered.Design View Post
            Thanks 6ixpool and Nawrot, I think I've almost got this...

            I've added a timeline as per the below image:
            [ATTACH=CONFIG]81011[/ATTACH]

            but now I'm having "rubber banding" type issue. The camera rotates to the correct position smoothly as it should, but for about five or six seconds after the rotation, every time I rotate the camera it rotates back behind the mesh. I'm guessing I need to somehow stop the timeline once complete, but can't figure out how. I've tried a few different options such as breaking out the two comparative rotations with break rots and then comparing floats and feeding that into the stop exec on the timeline but to no avail...

            Couple of ways.

            1) as you said (using compare float on the yaw), BUT use a "Nearly Equal" with a generous error tolerance (0.1 or so) to avoid float errors when the yaw is like, 0.0000001° off. Also feed both floats into a Normalize Axis node (I think that's what it's called) so that you don't have issues where one float is -90 and the other is 270 so they don't compare right.

            2) an easier way (one I use) is to just experiment and see about how long it takes to lerp the rotator back into position and make the timeline marginally longer than that. So if the rotation correction usually takes 1.4s, make the Timeline only 1.6s in duration so it auto-stops once "complete" (even though it can't know this for sure).

            3) The easiest way of all is to use the old Banjo-Kazooie method; when you press MMB, the corrective timeline loops, and it stops as soon as MMB is released. So you can hold MMB to correct the camera but release it any time if you need to regain control.

            Comment

            Working...
            X