i have problem on player movement with direct method
the problem is i have some rooms whit some cams on them and when player walk from one room to other and when camera switched then direction change instenly . i searche and found
this and i think this is same as mine so i try to write that custom script but this is not working at all . so if iam going to right way then where is the problem ?
my code
* Adventure Creator
* by Chris Burton, 2013-2016
*
* "ActionTemplate.cs"
*
* This is a blank action template.
*
*/
using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endifnamespace AC
{
[System.Serializable]
public class cameraLockSnap : Action
{
// Declare variables here
public cameraLockSnap ()
{
this.isDisplayed = true;
category = ActionCategory.Custom;
title = "Lock Direction";
description = "this is to avoid the player moving in unwanted directions when the camera cuts.";
}
override public float Run ()
{
/*
* This function is called when the action is performed.
*
* The float to return is the time that the game
* should wait before moving on to the next action.
* Return 0f to make the action instantenous.
*
* For actions that take longer than one frame,
* you can return "defaultPauseTime" to make the game
* re-run this function a short time later. You can
* use the isRunning boolean to check if the action is
* being run for the first time, eg:
*/
if (!isRunning)
{
AC.KickStarter.playerInput.cameraLockSnap = true;
return defaultPauseTime;
}
else
{
isRunning = false;
return 0f;
}
}
#if UNITY_EDITOR
override public void ShowGUI ()
{
// Action-specific Inspector GUI code here
AfterRunningOption ();
}
public override string SetLabel ()
{
// Return a string used to describe the specific action's job.
string labelAdd = "";
return labelAdd;
}
#endif }
}
Comments
override public float Run ()
{
AC.KickStarter.playerInput.cameraLockSnap = true;
return 0f;
}
i do what you say but still problem exist i use this custom action on the action list trigger that switched camera but still when player go from one room to other and when trigger switched cam the player movement direction changed
The camera lock snap should automatically set itself to false if the input direction angle after a camera switch changes by more than 5 degrees. Perhaps this is what's occuring - you can find out by opening PlayerInput.cs, and find the line:
if (newMoveKeys.sqrMagnitude < 0.01f || Vector2.Angle (newMoveKeys, moveKeys) > 5f)
If you change that "5f" to say "20f", does the problem go away? It may be that you need to find the best value that suits you.
this is a small video from game scene that show the situation . this will happend whit WSAD to.
so can you tell me when that version comes out and it be safe (without any problem like broken projects and so on )to update when my game is almost done after 4 month of working ?
if (KickStarter.stateHandler.gameState == GameState.Normal && KickStarter.settingsManager.movementMethod == MovementMethod.Direct && KickStarter.settingsManager.directMovementType == DirectMovementType.RelativeToCamera && KickStarter.settingsManager.inputMethod != InputMethod.TouchScreen && KickStarter.playerInput != null)
with
if (KickStarter.stateHandler.gameState == GameState.Normal && KickStarter.settingsManager.movementMethod == MovementMethod.Direct && KickStarter.settingsManager.directMovementType == DirectMovementType.RelativeToCamera && KickStarter.playerInput != null)