![]() Therefore, we need some limiters for specifying lane zones. Lanes’ levels can change throughout the game level based on the designer’s specific needs, or can be interrupted altogether and another camera tracking system can take their place. A lane should be changed only if the player’s character is going to stay on it for a while. While the character remains within the boundaries of this lane the camera will be moving only horizontally on lane specific height offset we can set.Īs soon as the character enters another lane, the camera will transition to that lane and continue to move horizontally from there on until the next lane change occurs.Ĭare must be taken on lane design in order to prevent fast lane switching during actions like jumps, which can create confusion for the player. The character is initially on the lower lane. The camera system we are building here is targeted at 2D platform games, but can easily extended to other types of 2D games, 2.5D games or even 3D games. ![]() It has a basic core consisting of several components which will ensure the basic functionality, and then various components/effects that can be optionally used, depending on the situation at hand. The camera system we are going to design together is modular and extensible. From 2D to 2.5D: An Extensible Camera System In this article I’m going to explain how to design a camera system for 2D games, and I’m also going to explain some points on how to go about implementing it in one of the most popular game engines out there, Unity. From just showing your game view in a chess app to masterfully directing camera movement in a 3D AAA game to obtain cinematic effects, cameras are basically used in any video game ever made, even before actually being called “cameras”. If you hover over each of the variables, you should be able to see which variable is equal to zero.For a developer, the camera is one of the cornerstones of the game development process. To debug this problem in the future, try inserting a breakpoint at the problematic line and attaching your IDE to Unity. Try changing Update() to FixedUpdate() if you do this you will need to use Time.fixedDeltaTime instead. You could remove ltaTime if #1 doesn't work, but I agree with you that the statement should be in there to keep the game consistent across framerates.Check your project settings/other scripts to make sure Time.timeScale is not equal to zero.Potential Problem 2: ltaTimeĪs said by in the comments, the ltaTime statement might be problematic. (excluding direction) or move the direction assignment statement to your Update() method. ![]() That means direction ends up being 0 and is never changed again.Įither change your line to rb2d.velocity = new Vector2(speed * ltaTime, ) You are probably not pressing any keys/moving any joysticks the frame that the scene starts up. You seem to only be setting direction once, in Start(): direction = Input.GetAxisRaw("Horizontal") One of these three variables must be zero to cause your problem. If we look at your code, the problematic statement should be here: rb2d.velocity = new Vector2(speed * direction * ltaTime, ) If someone could help that would be appreciated. ![]() Rb2d.velocity = new Vector2(speed * direction * ltaTime, ) rb2d.AddForce(new Vector2(speed * direction * ltaTime, 0)) If ((Input.GetKey(Ke圜ode.LeftShift) || Input.GetKey(Ke圜ode.RightShift)) & ((Input.GetKey("right") || Input.GetKey("d")) || Input.GetKey("left") || Input.GetKey("a")))Įlse if (!(Input.GetKey(Ke圜ode.LeftShift) || Input.GetKey(Ke圜ode.RightShift)) & (Input.GetKey("right") || Input.GetKey("d")))Įlse if (!(Input.GetKey(Ke圜ode.LeftShift) || Input.GetKey(Ke圜ode.RightShift)) & (Input.GetKey("left") || Input.GetKey("a"))) Transform.position = new Vector3(Mathf.Clamp(, -199, 197), Start is called before the first frame updateĭirection = Input.GetAxisRaw("Horizontal") Public class PlayerController : MonoBehaviour Here is the code: using System.Collections I tried using AddForce() instead of changing Rigidbody2D.velocity but that didn't work either, and after 2 or 3 days I still couldn't find a solution. I was making a 2D player controller and it worked until the day after I made a follow camera script, and now my character can't move but the animation still works.
0 Comments
Leave a Reply. |