Forum rules - please read before posting.

Character instantly changes direction when camera switches

Heya there!

The thing mentioned in the title isn't a bug or something. It does work as intended.
When controls are direct (controller or WASD; Telltale Style) and I press into one direction, the character walks always into this direction from the cameras point of view.
In my problematic scenario I let my character walk straight, the camera changes and shows the straight corridor from an angle, and instantly the character walks into a wall.

Is there an option that "checks" the cameras point of view only if the direction on my gamepad was changed (or if I stopped)?
This would also mean that, as long as I keep this one direction pressed, the character will walk in a straight line, no matter which camera I switch to. I observed this with all the TTG title, as well as other 3D adventures.

Thats already it! I hope it made sense to you :D

Cheers!

Comments

  • Actually, that exact behaviour should kick in automatically - provided you aren't controlling with a Touch Screen.

    The movement direction should remain the same after a camera cut, until either the input's magnitude drops below 0.1, or the input angle changes by 5 degrees (you can see these checks made in PlayerInput.cs, line 1090).

    Try inserting the following code line just above that line, 1089:

    Debug.Log ("Magnitude: " + newMoveKeys.magnitude + ", Angle: " + Vector2.Angle (newMoveKeys, moveKeys));

    That should give you a clue when playing - you may need to tweak the code value checks (e.g. the 5 degrees) to get the right behaviour.
  • Ohhh...
    Maybe I did something fancy that prevented that!

    I'll check it out once I do another test scene.
    Thanks a lot!
  • After some testing we found out that you are (of course) correct.
    If we do a 0 second long switch to another camera, the movement will be continued until you change it.
    However! As soon as you have a transition time in there (we had 6 seconds) the characters movement will change according the the view of the camera.

    Do you have an idea how we could provide the same control scheme (movement doesn't change when camera switches) to a switch with transition times?

    Thanks a lot so far!
  • The "lock direction" effect is enabled with the public boolean cameraLockSnap in PlayerInput.  You could write a custom Action that sets this bool to True just before switching Camera.  The Action would only need to run the following line:

    AC.KickStarter.playerInput.cameraLockSnap = true;

    A tutorial on writing custom Actions can be found here.
  • As always, thanks for the quick response!
    I'll try to test this as soon as possible :)
  • Hi!

    I've had the exact same problem and managed to work around it by writing the custom Action.
    The direction stays the same but as soon as i release the input-button the player rotates on the spot to face the new camera. 

    Is there a way to disable that?

    Hope to hear from you
    ~B 
  • @bveress: Are you using the keyboard or a controller for your input?  If keyboard, it could be due to how Unity reacts to a sudden depress of keyboard keys.  Are you pressing just one keyboard key or two?
  • at the moment I'm using the keyboard for input, and so far the rotation happens no matter if i just press one or two keyboard keys.

  • I revisited this issue while working on the prototype and found out that the sudden change in direction (different in your case, in mine it was while the camera was switching), was caused by the fact that the Actionlist that got fired while running through a trigger (basically the Camera:Switch Action that changes the camera) was not marked as "Run in Background".

    Maybe the cause to your problem is of similar nature?
  • Oh i see!
    Is there a line of code to write into the custom action to make it run in the background?

    Thank you so much for tip!
  • Running Actions in the background is a setting of the ActionList in which they're run, not the Actions themselves.  In your ActionList's / Cutscene's Inspector, find the When running field in their Properties box and set it to Run In Background.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.