|
Post by TrashPanda on Oct 9, 2020 12:31:44 GMT
I've just downloaded this and it has a flaw, unfortunately. It will only ever work if the destination end-point is in a straight, uninterrupted line.
This line:
_char.GetTargetPosition(true)
Gets the last node on the path, so if the path destination is behind a wall, it will run towards the wall and try to run through it.
I have already integrated another character controller into AC which uses a similar method of simulating input. I will modify that, test it and upload here. Give me 10 minutes...
|
|
|
Post by TrashPanda on Oct 9, 2020 13:32:19 GMT
OK, I've modified the AC bridge script, it is not perfect and can definitely be improved. But at least this will allow you to follow paths that aren't in straight lines.
Please feel free to use this however you wish.
using UnityEngine; using Invector.vCharacterController; using AC;
public class vInvectorACLink : MonoBehaviour { #region Unity Properties
[SerializeField, Tooltip("The distance to the target that we start to slow down")] private float _slowdownDistance = 2f;
[SerializeField, Space, Tooltip("The minimum slowdown coefficient")] private float _minimumSlowdownFactor = 0.5f;
[SerializeField, Space, Tooltip("The distance that we consider a path node reached")] private float _stoppingDistance = 0.75f;
public bool disableDuringGameplay = true; public bool inCutscene;
#endregion
#region Members
private vThirdPersonInput vInput; private Char _char; private float _squaredSlowdownDistance; private float _squaredStoppingDistance; private Paths _currentPath; private int _currentPathNodeIndex = 0;
#endregion
private void Start() { vInput = GetComponent<vThirdPersonInput>(); _char = GetComponent<AC.Char>(); _squaredSlowdownDistance = Mathf.Pow(_slowdownDistance, 2f); _squaredStoppingDistance = Mathf.Pow(_stoppingDistance, 2f); }
private void Update() { if (disableDuringGameplay) { if (KickStarter.stateHandler && KickStarter.stateHandler.gameState == GameState.Cutscene && _char.IsMovingAlongPath()) { inCutscene = true; SetCharacterPosition(); } else if (inCutscene) { inCutscene = false; ClearCharacterPosition(); } } else { SetCharacterPosition(); } }
private void SetCharacterPosition() { // Check if this is a new path var activePath = _char.GetPath(); if (_currentPath == null || (_currentPath.Destination - activePath.Destination).sqrMagnitude > 0.2f) { _currentPath = activePath; _currentPathNodeIndex = 1; }
// Check if this path is valid or not if (_currentPath == null || _currentPathNodeIndex >= _currentPath.nodes.Count) { ClearCharacterPosition(); return; }
var finalDestination = _currentPath.Destination; var destination = _currentPath.nodes[_currentPathNodeIndex];
// check if we have reached the current node if ((destination - KickStarter.player.transform.position).sqrMagnitude <= _squaredStoppingDistance) { // if this is the last node then we have finished if (_currentPathNodeIndex + 1 == _currentPath.nodes.Count) { vInput.cc.input = Vector2.zero; return; }
_currentPathNodeIndex += 1; destination = _currentPath.nodes[_currentPathNodeIndex]; }
var isLastNode = _currentPath.nodes.Count == _currentPathNodeIndex + 1; Vector3 dir = destination - KickStarter.player.transform.position; var squaredDistanceToNode = dir.sqrMagnitude; dir.Normalize(); var speedModifier = Vector3.one;
// Apply the slowdown speed modifier if (isLastNode && squaredDistanceToNode <= _squaredSlowdownDistance) speedModifier *= Mathf.Max(squaredDistanceToNode / _squaredSlowdownDistance, _minimumSlowdownFactor);
// If we are walking then we half the speed if (!_char.isRunning) speedModifier *= 0.5f;
// scale the movement vector by the speed modifier dir.Scale(speedModifier);
var targetDir = vInput.cc.isStrafing ? transform.InverseTransformDirection(dir) : dir; vInput.cc.input = targetDir; }
private void ClearCharacterPosition() { vInput.cc.input = Vector2.zero; }
public void SetRotateByWorld() { vInput.cc.rotateByWorld = true; }
public void SetRotateByCamera() { vInput.cc.rotateByWorld = false; }
public void LockPlayerInput() { vInput.SetLockBasicInput(true); }
public void UnlockPlayerInput() { vInput.SetLockBasicInput(false); }
public void LockPlayerCamera() { vInput.SetLockCameraInput(true); }
public void UnlockPlayerCamera() { vInput.SetLockCameraInput(false); } }
|
|
adamaze
New vMember
Peace
Posts: 22
|
Post by adamaze on Oct 10, 2020 4:22:56 GMT
Invector TPC camera controller doesn't work when game camera script is added(Display 1 no cameras rendering). On the other hand I dont need to use any script to use Invector TPC with AC but other camera will break the TPS controller when doing a camera switch
|
|
|
Post by TrashPanda on Oct 10, 2020 8:02:10 GMT
Invector TPC camera controller doesn't work when game camera script is added(Display 1 no cameras rendering). On the other hand I dont need to use any script to use Invector TPC with AC but other camera will break the TPS controller when doing a camera switch You have it configured incorrectly, I had the same issue when I first integrated another controller into AC. If you follow the guide in the AC manual to integrating a third party controller. You need to get the configuration right, I can't remember off the top of my head but it's something along the lines of removing the 'MainCamera' tag from the Invector camera then adding the BasicCamera component. Have a read of the AC manual it will explain all. Either way this is not a fault of the Invector integration or AC, it is config. Edit: You will need to use an integration script if you want the two to interact properly. That is allow the AC actions to control the player etc.
|
|
adamaze
New vMember
Peace
Posts: 22
|
Post by adamaze on Oct 10, 2020 18:25:57 GMT
Hi Monotonic
I just figure it out. I dont have another camera with a maincamera tag on it in my scene. Spent the last few days figuring it out. If i were to add the game camera script to my TPC camera and set its tag to maincamera, in wont work. So adding a dummy main camera solve the issue. But you are correct about the link script though. Cant lock Invector inputs without it.
Thanks
|
|
|
Post by TrashPanda on Oct 10, 2020 18:38:34 GMT
Hi adamazeYes, that's it. You need to add a dummy main camera, which is completely bizarre but I'm sure there's a reason for it. This is one of those things that you do once and then don't touch until the next project. Anyway, I'm glad you got it sorted out, happy coding
|
|
adamaze
New vMember
Peace
Posts: 22
|
Post by adamaze on Oct 11, 2020 15:29:03 GMT
If you wish to disable shootermelee attack input, Use this vInvectorAClink script. Use onStartGame action list.
using UnityEngine;
using Invector.vCharacterController;
using AC;
public class vInvectorACLink : MonoBehaviour
{
//private vThirdPersonInput vInput;
private vShooterMeleeInput vInput;
private Char _char;
public bool disableDuringGameplay = true;
public bool inCutscene;
private void Start()
{
//vInput = GetComponent<vThirdPersonInput>();
vInput = GetComponent<vShooterMeleeInput>();
_char = GetComponent<AC.Char>();
}
private void Update()
{
if (disableDuringGameplay)
{
if (KickStarter.stateHandler && KickStarter.stateHandler.gameState == GameState.Cutscene)
{
inCutscene = true;
SetCharacterPosition();
}
else if (inCutscene)
{
inCutscene = false;
ClearCharacterPosition();
}
}
else
{
SetCharacterPosition();
}
}
private void SetCharacterPosition()
{
if (_char.GetPath())
{
Vector3 dir = _char.GetTargetPosition(true) - KickStarter.player.transform.position;
dir = dir.normalized * Mathf.Clamp(dir.magnitude, 0f, 1f);
var targetDir = vInput.cc.isStrafing ? transform.InverseTransformDirection(dir).normalized : dir.normalized;
vInput.cc.input = targetDir;
}
else
{
ClearCharacterPosition();
}
}
private void ClearCharacterPosition()
{
vInput.cc.input = Vector2.zero;
}
public void SetRotateByWorld()
{
vInput.cc.rotateByWorld = true;
}
public void SetRotateByCamera()
{
vInput.cc.rotateByWorld = false;
}
public void LockPlayerInput()
{
vInput.SetLockBasicInput(true);
}
public void UnlockPlayerInput()
{
vInput.SetLockBasicInput(false);
}
public void LockPlayerCamera()
{
vInput.SetLockCameraInput(true);
}
public void UnlockPlayerCamera()
{
vInput.SetLockCameraInput(false);
}
public void LockPlayerMeleeInput()
{
vInput.SetLockMeleeInput(true);
}
public void UnlockPlayerMeleeInput()
{
vInput.SetLockMeleeInput(false);
}
}
|
|
|
Post by TrashPanda on Oct 11, 2020 17:00:52 GMT
Hi adamaze,
That still only walks in a straight line though, if you set a destination that requires moving around obstacles it will fail. If you compare the functionality of that to the sketch code I posted above you will see the difference.
Also, this is supposed to be a base that people build on, vThirdPersonInput is the base for all the Invector input types, changing it to vShooterMeleeInput makes it less generic and would fail for anybody looking to build upon it. It is a good addition for sure, but I would still reference the base class (vThirdPersonInput) then in the UnlockPlayerMeleeInput for example I would do
(vInput as vShooterMeleeInput)?.SetLockMeleeInput(false);
|
|
neko
New vMember
Posts: 2
|
Post by neko on Oct 26, 2020 7:16:47 GMT
Hello guys! I hope you guys can give me a hand with this problem. I am trying to integrate Adventure creator and I was following the video tutorial in the Invector channel. However, there is a step in the video that requires the adding of the V Invector AC link Script as a component to the player, but it doesn't show up for me at all. Does the V Invector AC link Script needs to be downloaded from somewhere else? By the way, I am using the Melee combat template. Thanks in advance Hi Have you download the invectorACintegrationpackage? go to the 1st page of this section and look under the tutorial video where you can download. After downloading just click on it to import the package in your project If you have done so just add a component on your player and at the search box type in "link". You will see that V invector link script pop up.. just select that.. and follow the rest of the tutorial
|
|
|
Post by coderdaudat on Dec 21, 2020 10:32:02 GMT
Hi there,
I tried to add a joystick to the demo (I downloaded it from the first page). I built and ran the demo on an android device but an error occurs: cannot see the character
|
|
|
Post by G 4 greatness on Feb 27, 2021 23:18:35 GMT
This add on is not working with version 2.5.6
|
|
|
Post by kezako on Mar 15, 2021 22:14:28 GMT
I wanted to use AC + invector this weekend for a game jam ... I was disappointed to see that it was not updated ... @invector can you update it please?
|
|
|
Post by kezako on Jun 26, 2021 12:08:36 GMT
Thanks for the update @invector
|
|
noir
Full vMember
Posts: 57
|
Post by noir on Nov 16, 2021 0:46:39 GMT
My game runs smooth until I add AC menu. Not sure wy?
|
|
|
Post by azathot333 on Mar 25, 2022 17:39:12 GMT
genial, ¿esto significa que puede cambiar todas las demás tareas del proyecto que incluyen hacer que parkour y colisionadores estén bajo el creador de aventuras sin tener ningún conflicto con invector tpc? Hola Creador tengo un problema instale el asset adventure pero me marca estos dos errores ¿hay alguna solucion?
Gracias
Assets\InvectorIntegration\vInvectorACLink.cs(4,7): error CS0246: The type or namespace name 'AC' could not be found (are you missing a using directive or an assembly reference?)
Assets\InvectorIntegration\vInvectorACLink.cs(9,13): error CS0246: The type or namespace name 'Char' could not be found (are you missing a using directive or an assembly reference?)
|
|