|
Post by Strider on Jul 16, 2018 20:56:17 GMT
Sorry, i made a mistake and now it works quite well.
Sorry again :P
|
|
gus
New vMember
Posts: 9
|
Post by gus on Jul 22, 2018 22:41:13 GMT
Any news on this script? want to implement it again but is not working :( I'm also trying to implement it again and it's not working, any updated code?
|
|
|
Post by Strider on Jul 25, 2018 2:11:25 GMT
in the end i didn't update any code, just selected everything and replaced all the "jump" section in the file, and it worked quite fine!
|
|
leoo
New vMember
Posts: 6
|
Post by leoo on Jun 16, 2019 16:27:08 GMT
for those who needs help if its not working
just copy and paste the multijump code in the jump methods region on motor then also replace the jump() with the copied code for the controller , then you will find the amount of jumps or multi jumps on the grounded options in inspector
:D
|
|
|
Post by bighale on Jun 18, 2019 23:35:26 GMT
I'm currently using version 2019.1.3f1 and when I plug in the code I get this error in a different script that none of the code was in. Does anyone have an idea of what I need to add to get this to work. Thanks
|
|
|
Post by kezako on Aug 27, 2019 22:46:31 GMT
hello i use unity 2019 1.4f1 and the latest version of invector shooter 1.3.2. I managed to run this little addon, so I share with you how.
vThirdPersonMotor.cs
// insert in #region Character Variables line 87 [Tooltip("Increase number to enable multiple jumps on your character")]
[Range (1, 10)]
public int MultiJump = 1;
[HideInInspector]
public int currentMultiJump;
vThirdPersonController.cs
// replace/modify Jump function
public virtual void Jump(bool consumeStamina = false)
{
if (animator.IsInTransition(0)) return;
// know if has enough stamina to make this action
bool staminaConditions = currentStamina > jumpStamina;
// conditions to do this action
bool jumpConditions = !isCrouching && !customAction && staminaConditions;
// check if multi jump is possible
if (MultiJump > 1)
{
// reset multi jump counter
if (isGrounded) currentMultiJump = 0;
// check if we reached the max jump value
jumpConditions = jumpConditions && currentMultiJump < MultiJump;
// increase multi jump counter
if (jumpConditions)
{
currentMultiJump++;
// zero out velocity before next jump
Vector3 jumpVelocity = _rigidbody.velocity;
jumpVelocity.y = 0f;
_rigidbody.velocity = jumpVelocity;
}
}
else
{
// single jump conditions
jumpConditions = jumpConditions && isGrounded && !isJumping;
}
// return if jumpConditions is false
if (!jumpConditions) return;
// trigger jump behaviour
jumpCounter = jumpTimer;
isJumping = true;
// trigger jump animations
if (speed < 0.1f)
animator.CrossFadeInFixedTime("Jump", 0.1f);
else
animator.CrossFadeInFixedTime("JumpMove", 0.05f);
// reduce stamina
ReduceStamina(jumpStamina, false);
currentStaminaRecoveryDelay = 1f;
}
|
|
|
Post by xianno on Dec 28, 2019 7:40:13 GMT
[EDIT] I managed to make it work for the 2.5.0 update. Here are the codes you need to add : in "vThirdPersonMotor" :Insert it region Character line 87.[Tooltip("Increase number to enable multiple jumps on your character")] [Range (1, 10)] public int MultiJump = 1; [HideInInspector] public int currentMultiJump; in "vThirdPersonController" : replace Jump method by this one line 220.public virtual void Jump(bool consumeStamina = false) { if (animator.IsInTransition(0)) return;
// know if has enough stamina to make this action bool staminaConditions = currentStamina > jumpStamina;
// conditions to do this action bool jumpConditions = !isCrouching && !customAction && staminaConditions && currentMultiJump < MultiJump;
// check if multi jump is possible if (MultiJump > 1) { // reset multi jump counter if (isGrounded) currentMultiJump = 0;
// check if we reached the max jump value jumpConditions = jumpConditions && currentMultiJump < MultiJump;
// increase multi jump counter if (jumpConditions) { currentMultiJump++;
// zero out velocity before next jump Vector3 jumpVelocity = _rigidbody.velocity; jumpVelocity.y = 0f; _rigidbody.velocity = jumpVelocity; } } else { // single jump conditions jumpConditions = jumpConditions && isGrounded && !isJumping; }
// return if jumpConditions is false if (!jumpConditions) return;
// trigger jump behaviour jumpCounter = jumpTimer; isJumping = true; OnJump.Invoke();
// trigger jump animations if (input.sqrMagnitude < 0.1f) animator.CrossFadeInFixedTime("Jump", 0.1f);
else
animator.CrossFadeInFixedTime("JumpMove", 0.05f);
// reduce stamina
if (consumeStamina)
{
ReduceStamina(jumpStamina, false);
currentStaminaRecoveryDelay = 1f;
}
} in "ShooterMeleeInput" , "MeleeCombatInput" & "vThirdPersonInput": replace codes line 273 in "vThirdPersonInput" by the following ones, and do the same for codes line 293 in "ShooterMeleeInput" if you want to use the double jump with the ShooterMelee template. To use it with the MeleeCombat Template, replace lines 150 to 153 in "MeleeCombatInput" by the following codes too. protected virtual bool JumpConditions()
{
return !cc.customAction && !cc.isCrouching /*&& cc.isGrounded*/ && cc.GroundAngle() < cc.slopeLimit && cc.currentStamina >= cc.jumpStamina && !cc.isJumping;
}
protected virtual void JumpInput()
{
if (jumpInput.GetButtonDown() && JumpConditions())
cc.Jump(true);
} in the AnimatorController of your Character :Tag the Airborne state in the animator controller as "Airborne" like in the image above.
|
|
|
Post by drmarvellous on Feb 13, 2020 22:00:20 GMT
Hi folks, I'm struggling to get this double jump to work, I've copied the code examples into the 3 different scripts as posted above and I can see the "MultiJump" option appear in the Inspector under ThirdPersonController script - Jump/Airborne section, but I cannot get anymore than a single jump.
Q: Is there some additional tweak, or is that all you did?
Many thanks.
|
|
|
Post by xianno on Feb 16, 2020 9:43:21 GMT
Hi folks, I'm struggling to get this double jump to work, I've copied the code examples into the 3 different scripts as posted above and I can see the "MultiJump" option appear in the Inspector under ThirdPersonController script - Jump/Airborne section, but I cannot get anymore than a single jump. Q: Is there some additional tweak, or is that all you did? Many thanks. Hey! First of all, make sure that you have tagged the quoted animations on "Airborne". If you are using an old AnimatorController from a previous version it may be some non-tagged animation and you need to get them tagged to use this script for some reasons. Please, try to use it with the Basic Controller in a demo scene first, then with your own to make sure that it's not the script but the AnimatorController. I've checked my post and I forgot to mention that you need to apply the third script in vThirdPersonInput too. My Bad! I've corrected it in my previous post. Can you check that everything is ok after that please?
|
|
|
Post by midgear on Feb 17, 2020 20:15:28 GMT
I too am having problems, I can get the multi jump show up on the Third person Controller but it's doing nothing in play.
Could just be me, I'm an art and level design person and all this coding stuff gives me a headache. So if you would be willing to idiot proof your instructions that would be super helpful.
Of note I have the free climb and swimming add on in my game I don't know if that would do anything but there you go.
|
|
|
Post by drmarvellous on Feb 18, 2020 10:43:01 GMT
Hi xianno, many thanks for the response. I've tried the additional update in script - "vThirdPersonInput", but it hasn't made any difference, still can't get the double jump, just like midgear above, it shows in the inspector, just not getting the feature. I wonder if I'm not fully understanding what you said about "make sure that you have tagged the quoted animations on "Airborne" Do you mean add a tag to the Airborne animation in the animator window? I want to make sure I'm not supposed to be seeing anything else in my animator window. I can't seem to ab able to add images in this post, otherwise I'd show you what I'm seeing. Hopefully there is some other way. I haven't yet tried it in the "Basic Controller in a demo scene" as you mentioned above. I'll test that now and report back. Thanks for your effort and help so far, it is appreciated.
|
|
|
Post by xianno on Feb 18, 2020 13:43:54 GMT
No problem guys, I had at first a lot of troubles making it work too! So I perfectly understand that you can encounter some issues. First of all, to make it work, you obviously need to add the codes I shared on my previous post. You really need to replace everything if it's said "replace", in some lines I commented or deleted a JumpCondition to make the player able to double/triple... jump. If it's just said "add", don't erase everything, and just add it raw at the quoted line. After that, you need to check if your animations in the Airborne state of your AnimatorController are well tagged on "Airborne" via the vAnimator Tag. I advise you to try first with the BasicLocomotion DemoScene to make sure that the problem is not from script, or from the AnimatorController as the Basic Locomotion's vThirdPersonCharacter will get an AnimatorController with all tags needed. Finally, you need of course to add extra jumps in the Jump area of your ThirdPersonController in the Editor. You may find a Slider to change the amount of jump! Here is a screenshot of the AnimatorController with the vAnimatorTag Airborne on the Airborne State. I don't remember having done anything more than explained in my post. Please, try this in a Demo Scene provided by Invector at first. If you can double jump in it, it's because something is wrong with your own character! As I said in my original post, this is for the version 2.5.0 of Invector. If you are using an older version, use previous posts in this thread to help you! You can use it with every Invector Add-Ons. Fuel it up guys ~
|
|
|
Post by drmarvellous on Feb 18, 2020 15:56:47 GMT
Hey xianno, I can confirm that this does work great with the Basic Controller in the demo scene using V2.5.0, so good to know the steps are bang on, thank you. Also, all the images you shared, regarding the Airborne tag, I did have the exact same setup, so that's good to see. I'm using the "Melee Combat controller" in my 2.5D game, but cannot get the multi jump to work in that, so I'm guessing it's something else in one of the scripts associated with that, right?
|
|
|
Post by midgear on Feb 18, 2020 17:24:25 GMT
Same thing with the melee combat thing for me, there seems to be nothing to replaced in the ShooterMeleeInput at or around line 293 I tried adding it in line 293 but still nothing. The Basic Controller also works fine for me it's just the Melee characters that aren't working.
|
|
|
Post by midgear on Feb 18, 2020 17:37:27 GMT
AH HA! it was the wrong script! So instead of ShooterMeleeInput you want to go to vMeleeCombatInput and replace line 150 to 153 with the code xianno gave us: protected virtual bool JumpConditions()
{ return !cc.customAction && !cc.isCrouching /*&& cc.isGrounded*/ && cc.GroundAngle() < cc.slopeLimit && cc.currentStamina >= cc.jumpStamina && !cc.isJumping;
}
protected virtual void JumpInput()
{
if (jumpInput.GetButtonDown() && JumpConditions())
cc.Jump(true);
} That got it working for me.
|
|