Sorry about the title I didnt know what to name the topic, but I need help and I’ve tired to find a solution for something so basic and I cant do it its frustrating me and before i give u on my project i’d rather ask for help. So i’m creating Donkey Kong some have seen my project thread but most probably haven’t in the thread many people have suggested I center the player as he goes up the ladder, I agree and so I’ve been working on this and I can do it once as you can see here
But I run into a problem if I want to do it more than once. I cannot figure out how. I have tried to think of solutions but to no avail I’ve been trying for about 2 hours and I’m getting quite annoyed because I know the answer has to be simple. Any solutions on how I can center the player on each ladder in the game
as you can see I have many ladders in there and I need the player to be centered when climbing that ladder. Please someone just point me in the right direction…
Oh I’d like to point out i’d like to do this without a crap load of variables or tags
Can you show or tell us how you made it work once?
Edit: But in principle it’s really simple. You must already know when he’s climbing a ladder and which one he’s climbing, that’s all you need to know. When he’s climbing a ladder, just set the horizontal component of his position to match the horizontal component of the ladder’s position.
private void Climb(){
if(Input.GetKey(KeyCode.UpArrow) canClimb == true){
//Makes the player centered on the first ladder
Vector3 pos = transform.position;
pos.x = 1.93f;
pos.y += climbSpeed * Time.deltaTime;
transform.position = pos;
climbing = true;
gravityForce = 0;
}
}
This is my style of coding and it may or may not be the most efficient, basically i have thought to set up tags for each ladder but it wouldn’t work i’ve thought to use variables when he enter a trigger but how do i know which trigger he entered on a level with two ladders. I even thought to use arrays but I dont think that would work, I am stumped…
any suggestions or pushes in the right direction would be great
Edit: I know this
What i dont know is how to do this for each individual ladder