Hello I have the first person controller, I wat to do that:
When player enters on especific radius a message appear that you can press E to climb a wall to enter on an air vent, also ignore player controll while player is doing that mini animation.
Im kinda new on unity and I dont know where to start, can anyone give me some hints on how to do that? thanks
You’re asking for quite a bit. I would highly reccomend getting more comfortable with the fundamentals of programming.
Essentially, you need to declare a few flags that can determine if you’re in climb-mode. From there, you can add logic to disable the character controller when in climb-mode and play your animation.
Okay I did this to climb walls but still some bugs:
When I press E on the zone the character starts an animation climbing (it just swaps the camera and move y axis up) then the player moves where the climbing camera finished, after that I swap the camera to the air vent camp ( i’ts like you are crouched walking) I dont know if this is correct for do that, also character can press E multiple times and start doing the animation a lot of times dunno how to solve that, what do you guys think about that script? any advices, tips?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
public class climbing : MonoBehaviour {
private bool canClimb;
public Animator anim;
public Camera climbingCam;
public Camera regularCam;
public Camera ventCam;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (canClimb && Input.GetKeyDown(KeyCode.E))
{
canClimb = false;
regularCam.depth = 0;
climbingCam.depth = 1;
anim.SetBool("Climb", true);
StartCoroutine(afterClimb());
}
}
IEnumerator afterClimb ()
{
yield return new WaitForSeconds(2);
ventCam.depth = 1;
climbingCam.depth = 0;
anim.SetBool("Climb", false);
transform.position = climbingCam.transform.position;
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Climb")
{
canClimb = true;
}
}
private void OnTriggerExit(Collider other)
{
canClimb = false;
}
}
maaaybe like this ??
idk if it makes a difference… i cant remember exactly, but in my experience some code was wonky and wanted its own if() … maybe that ??
i dont see any glaring problem with your code… so maybe?