I’m a high school student, 17 years old, because I’m doing a 2d platform video game, and there’s something I do not understand how it works, since I’m looking for the camera to start moving as a ghost object moves so that the character is not centered and has That up as it is up, well I was dealing with the notifications for the moment the character jumps (since I plan to introduce a small tutorial indicating the controls at every start, android) so that the ghost will start to move and So the camera also, the problem is that I can not make the ghost move continuously, and only moves a little as long as the character jumps, also the same happens to the random call platforms, which I hope to start when the Character jump but these explode and are called each frame making it unplayable, please if someone understands what I mean, leave your answer or some video to help me understand how it works Correctly, since I do not seek to copy code but to learn how to do it, thanks
hi, it sounds like you need to watch a few videos on transform moving.
the questions you asked are way to generic for us to give good answers.
the camera is not following the player issue. for starters, is the camera a child object of the player? that can bee an easy fix.
the character not being centered. center of what? the view port?
what is this ghost you speak of? character jump = ghost moving. that’s weird. but most likely a code issue. you have something checking if it’s true, and when rue the ghost moves. we will need to see some of your code to help with this
Thanks for the answer, sorry for not explaining correctly, what I did was that the camera does not follow the character but an invisible or ghost object so that the character is not centered and the character can be destroyed when leaving the screen, well what I want To do is that the “ghost” begins to move in the moment that the character jumps, but the problem is that the movement is not continuous and only moves a frame
the ghost object we call an empty gameObject in unity. so just create an empty gameObject and rename it to ghost, then drag the camera to the ghost, and drag the player to the ghost.
The move script should also be on the ghost, not the play or the camera. This way when you move the ghost the other 2 will follow.
i’m assuming you have a getkey if statement to detect when the WASD keys are pressed. and this if statement is in the Update() function for the move script.
We will need to see some code to better help.
void Update() {
if (Input.GetKey(KeyCode.W))
{
print("Up arrow key is held down");
}
if (Input.GetKey(KeyCode.S))
{
print("Down arrow key is held down");
}
if (Input.GetKey(KeyCode.A))
{
print("Left arrow key is held down");
}
if (Input.GetKey(KeyCode.D))
{
print("Right arrow key is held down");
}
}