- Home /
2D game with two point perspective and distortion?
I'm currently trying to understand perspective in 2D games specifically 2D drawn perspective with two vanishing points. A general rule with two point perspective is to place the vanishing points outside of the composition to avoid distortion. The thing is the scene I'm working on has two vanish points which are inside the composition and close to each other causing a "fish eye" distortion but without curved lines so it's a false perspective none the less my job is to write a script for movement within the scene.
My current plan is to attach two empty objects to the character one at the base of the feet for "root" location and movement and one at the top of the head to handle scaling. The bottom "root" point would move along the distorted plane using a vanishing point movement script and the top point would scale using the same vanishing point script. I originally set the camera to perspective to use z movement for perspective scaling but noticed that this wouldn't work since the camera only has one perspective point so I am working purely in orthographic. Any help would be appreciated as to how I would script something like this.
Based on a previous forum post I'm using this script for vanishing point movement.
var inputX = Input.GetAxisRaw("Horizontal");
var inputY = Input.GetAxisRaw("Vertical");
var multiplier = Mathf.Abs(vanishingPoint.position.y - transform.position.y) / maxDistance;
speedVert = Mathf.Lerp(0.2f, 3f, multiplier);
speedHor = Mathf.Lerp(0.2f, 3f, multiplier);
var vertDir = (vanishingPoint.position - transform.position).normalized;
var moveY = inputY * speedVert * Time.deltaTime;
transform.position += vertDir * moveY;
Here's the scene I'm working on showing vanishing points and distortion planes.
Answer by Bunny83 · Sep 04, 2021 at 10:07 PM
I think you overcomplicate the situation here. Movement should be based on the floor and your floor does converge in a single vanishing point in the middle when you follow the lines on the floor into the distance. There's another one right above the first one where the ceiling converges. However that's kinda irrelevant. Well it may be relevant for scaling but the position should only depend on the bottom vanishing point.
Your answer
Follow this Question
Related Questions
Sprite will not roate when arrow keys are pressed 2 Answers
Making a bubble level (not a game but work tool) 1 Answer
How can I stop the player movement from being too fast while moving diagonally in my 2D game? 2 Answers
Movement Problems PS4 Controller 0 Answers
Multiple enemy prefabs moving towards a single goal. Need help! 1 Answer