|
Post by fabian on Nov 28, 2017 23:13:49 GMT
Hi, I'm trying to lock the player's movement when he walks up to a NPC and a button is pressed but it doesn't really work. I see there's a "Lock Input" bool on the vThirdPersonInput. I manage to set this to true in my script and it does what I expected - disabling the input, which is good, but of course not enough. In the debug window I see there's another bool called lockMovement, but I don't really know how to set that to true. Right now my player character can walk to the NPC, and when I press the button while the player character is standing still, everything works fine and as intended. The player character is in idle-animation, standing still and input is disabled. But when I walk to the NPC & I press the button while the player character is still moving, he continues moving in a straight line which is obviously not what I want. Instead I want him to stop moving immediately when I press the button. GIF of the current behaviourI searched this forum and found this older thread, where someone else had a smiliar problem and I unsuccessfully tried the suggestions in there: Link to thread
At the end it is suggested to use canInput from the vThirdPersonInput, but I seem to be unable to use/find this. Can anyone help with this? I should mention that I'm quite a beginner when it comes to coding, so sorry if this is something super obvious that I'm missing Thanks!
|
|
|
Post by Jader on Nov 29, 2017 1:32:24 GMT
I use it that way, don't know if it's the right way:
using System.Collections; using System.Collections.Generic; using UnityEngine; using Invector.CharacterController;
public class Example : MonoBehaviour {
public vShooterMeleeInput vController;
void Start (){
vController = GameObject.Find ("myPlayer").GetComponent<vShooterMeleeInput>();
}
public void Lock(){
vController.LockInput (true); }
public void unLock(){
vController.LockInput (false); } }
|
|
|
Post by fabian on Nov 29, 2017 17:24:53 GMT
Thanks for the answer, but I should mention that I'm not using the Shooter or Melee template. Also unfortunately this doesn't really help as I'm having no problem with disabling the input, but the movement itself. The player just runs away after I disabled the input. I want to disable the input and at the same time disable all movement of the player.
|
|
|
Post by Jader on Nov 30, 2017 13:03:34 GMT
There a input script in your player, i think its vThirdPersonInput. You just have to change vShooterMeleeInput to vThirdPersonInput in my example script. I can't test now
|
|
|
Post by jamison on Nov 30, 2017 17:35:01 GMT
Has anyone found a solution to this? I am having the same problem.
|
|
|
Post by Devistute on Nov 30, 2017 18:26:23 GMT
Perhaps try to crossfade the animation to idle when needed?
|
|
|
Post by fabian on Dec 1, 2017 0:39:42 GMT
I think it hasn't really become clear what I'm trying to do. Basically I want to set this to true: But I dont know how to do that. Or even if that's the right approach to really stop the character. From what I understand, locking the input and the actual movement of the character are two different things (?) I tried to access the vThirdPersonController in my script and later say cc.lockMovement = true;
(cc is what I called the vThirdPersonController) But it doesn't really do anything. Has anyone an idea? And thanks for your help so far!
|
|
|
Post by jamison on Dec 1, 2017 1:09:12 GMT
I think that InputVertical, InputHorizontal, and InputMagnitude need to be set to 0, but I am not quite sure how to do that.
|
|
|
Post by Jader on Dec 3, 2017 1:06:56 GMT
Did you try this?
using System.Collections; using System.Collections.Generic; using UnityEngine; using Invector.CharacterController;
public class Example : MonoBehaviour {
public vThirdPersonInput vController;
void Start (){
vController = GameObject.Find ("myPlayer").GetComponent<vThirdPersonInput>();
}
public void Lock(){
vController.LockInput (true); }
public void unLock(){
vController.LockInput (false); } }
|
|
|
Post by fabian on Dec 3, 2017 13:08:43 GMT
Did you try this? using System.Collections; using System.Collections.Generic; using UnityEngine; using Invector.CharacterController; public class Example : MonoBehaviour { public vThirdPersonInput vController; void Start (){ vController = GameObject.Find ("myPlayer").GetComponent<vThirdPersonInput>(); } public void Lock(){ vController.LockInput (true); } public void unLock(){ vController.LockInput (false); } } I have to say sorry to you, as you mentioned this earlier and I thought you misinterpreted my question. But actually the mistake was on my side, as I thought the lockInput was working when it really wasn't. I tried your solution now and it works perfectly! Thank you so much, I am a big step forward now! For anyone who has similar issues, it has apparently nothing to do with the lockMovement bool, just using the code Jader posted worked (only change I made was removing the line in the start function, as this caused an error in my project. I'm also not sure why it's there, as you reference the player in the public vController, so removing the line in Start worked, at least for me)
|
|
|
Post by rabassa on Feb 1, 2018 15:00:30 GMT
Hi!
I'm using the Melee controller - works greats. However I'm having an issue with locking the input on the melee input manager for cut scenes. Specifically, when the player triggers a cut scene, I need the player to stop until the scene is over.
I'm doing this using Playmaker to enable the Lock Input and then play the timeline for the cut scene. But my player does not stop. I can see in the inspector that the Lock Input checkbox is checked (by Playmaker) but the player does not stop and in the Debug Window I can see that lockMovement always remains False.
If I check the Lock Input check box in the Melee Input Manager by hand (while in play mode), it will disable as expected although the LockMovement flag in the Debug Window does not change. Any suggestions?
thanks, rich
|
|
|
Post by madscientist on Jul 7, 2018 15:31:48 GMT
Hi! I'm using the Melee controller - works greats. However I'm having an issue with locking the input on the melee input manager for cut scenes. Specifically, when the player triggers a cut scene, I need the player to stop until the scene is over. I'm doing this using Playmaker to enable the Lock Input and then play the timeline for the cut scene. But my player does not stop. I can see in the inspector that the Lock Input checkbox is checked (by Playmaker) but the player does not stop and in the Debug Window I can see that lockMovement always remains False. If I check the Lock Input check box in the Melee Input Manager by hand (while in play mode), it will disable as expected although the LockMovement flag in the Debug Window does not change. Any suggestions? thanks, rich Hey dude! I have the exact same issue and this works for me. In the file vThirdPersonMotor.cs look for the FreeMovement() procedure and change this:
if (isSprinting) speed += 0.5f;
Into this: if (isSprinting) speed = (speed * 2); The problem is that the original line adds 0.5 to the speed value no maters what, so when you try to stop the player using the lockInput function while running, the speed is 1 and the resulting speed is 0.5 even if the character rig is actually frozen, because the animation keep playing in walk mode. So, with the code line modified you add the 0.5 in function to the current speed value instead of adding an absolute 0.5. As a result, when the lockInput is called, the speed becomes 0, and the new line adds another 0 to the current speed.... keep it on 0.... :-P
|
|