Hello everyone! I've used Adventure Creator to make two 2D games, but the next one is using 3D, so I'm moving into uncharted territory. However, the game is 2D'ish: Although there's some movement in depth, the majority of exploration limits only to walking left or right. The setting is an island which the player would be able to circle around, so there would be this looping track, a rim around a cylinder, so to speak.
My question is, how can I lock the camera to a side view of the character? The idea is that the game is a side-scroller where the camera follows the player in a similar manner as in a 2D game. The closest reference to the idea about the camera is Housemarque's Resogun:
This is the way the camera should follow the player. How can I achieve similar camera functionality using Adventure Creator?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
For this, you'll want a custom camera type, which is a case of creating a new script that derives from AC's _Camera class.
From the script's _Update function, you can then set the camera's position according to its Target's position relative to a pre-defined pivot/centre position.
Here's an example. Create a new C# script named SpinCamera, and attach it to a new Unity Camera in your scene. Fill in the fields and remove the Audio Listener component, and you can then assign it as your scene's default Camera, or switch to it using Actions.
Thanks Chris for a super speedy reply! Having some issues with this, though: I can't figure out what to insert Centre Point in the inspector. Should I have a game object located somewhere, and the camera anchors itself there, or what should I do?
I tried different Centre Points but it seems that the camera always points itself away from the player character.
Create a new GameObject put it in the centre of the scene, i.e. the centre of the circle the Camera should spin around, and then assign that as the "Centre Point" Transform.
Above that field in the Inspector will be the _Camera base class's fields - leave Target blank, but check "Target Is Player".
If in doubt, share screens and I'll take a look.
The behaviour should be that the camera is along the edge, and pointing to the centre - as it is in the video you shared.
You're saying that the camera is positioned in the centre, it at the "Centre Point" transform?
Please let's see some screenshots.
Okay, here's a screenshot: https://drive.google.com/file/d/14V7skScfgdNEEBPx0AdGiEYTNmzXcfjc/view?usp=sharing
The first image is of the camera in runtime and where it's pointing. The second image is the location of the player character and third one the spincamera's inspector. In hierarchy, the Spin Camera is located under _camers, and it's defined as the default camera in the scene.
You're dealing with a Terrain, yes? The distance values are very large.
The "Distance" field determines how far the camera is from the centre - this will need to be larger than at least half the width of the terrain.
Yup, distance was the culprit here Once I made my level more reasonable sized, the camera works exactly the way it's supposed to. Thank you very much!
Hello again!
Okay, the script @ChrisIceBox you provided works perfectly, but the design for camera behavior changed a bit, as we realized that navigating a round island is a bit boring. I noticed a thread where @Temmy asked about moving a gameobject on Spline (with Unity Bezier Solution: https://assetstore.unity.com/packages/tools/level-design/bezier-solution-113074), which seems to be the perfect solution on this project. We'd like to have a spline to be created on the edge of the island, and the player would move on this spline.
So, we're creating a game, that is on 3D, but functions as a side-scroller in a very 2D'ish manner. Basically the player would move only left or right, so moving along the spline would be the best way to achieve this.
So my questions are:
I really appreciate all the help. This is pretty simple stunt to pull of in 2D, but 3D is so new for me, so I'm probably asking very noobish stuff
If you wish to make use of a third-party bezier tool to define where the Player moves, you'll need to write a custom motion controller for the Player in order to have them move along it.
See the Manual's "Custom motion controllers" chapter for more on this topic, but I'd recommend first working on a controller in isolation, without the presence of any AC objects/components, as it'll be easier to integrate the two once you have something working by itself.
For an AC-only approach, it's possible to constrain a direct-controller Player to an AC Path object using the Player: Constrain Action. This'll force a Player to only move between points on the Path. It won't be curved, however, so you'd have to create many nodes on the Path to give it a smooth appearance.
The script above should allow for that - in what way is it different?
My programming skills are almost non-existent, so I think I'm going to go with the AC Path approach. I tried setting up a narrow corridor for the player to move with colliders, but that didn't work at all
Is there something specific I need to know to setup the path and especially to set the player to follow it? Do I need to do something specific regarding PlayerStart for example? I'm currently not on my development PC, so any tips to get a flying start in the evening would be greatly appreciated.
Now that I think of it, I think the camera script will work fine, the biggest issue at moment is the movement, and especially restricting it to two directions.
Thanks again for your reply!
It should be a case of just creating a Paths object, and using the Action I mentioned in your OnStart cutscene to limit movement. If you have a whole island to navigate, best to start with a simple test scene with just a few nodes to get a feel for how it works.
I'll give it a go, thanks. Would it be possible to use Tracks in this scenario to move the player in? The manual states that a Curved Track can be used to form a circle, and the player has control of the draggable objects, so could this kind of object be replaced with a player character?
I'm afraid not - the two are very different systems.
Are you looking to move the Player in a perfect circle? A bezier curve probably wouldn't be necessary for something that simple.
What is the behaviour now when moving left/right? Movement should be relative to the camera, so if the camera is spinning then so too should the Player.
No, the movement is not in perfect circle. We don't have a clear idea of the island layout at this point, so basically the player character should move in a loop around the island, and we should be able to affect the form of the loop. there are areas with height differences etc.
The character moves correctly at the moment with the spinning camera, the biggest issue is limiting the movement so that the game would run as a 2D platformer, only to left & right,
Okay, the path system works great for my purposes, but I've ran into a new problem: my character moves only left, so basically I can't reverse on the path. Ticking the reverse on the constrain action does nothing. What am I doing wrong?
If it helps, I'm using Tin Pot from the demo as the player character. Another thing I noticed is that although I have selected Loop from the Path inspector, the character is not following the path once it has reached the final node.
What is your AC version?
Try disabling the Animator component, but share screens as well of your setup - I'll attempt a recreation.
Okay, here's my Paths setup: https://drive.google.com/file/d/1lTb9VHV6fFiUjjy5dTzEC_axNGxVnfIP/view?usp=sharing
They form a circle, which the player should be able to travel in both directions. I tried disabling the animator on Tin Pot, but that didn't do anything. Do you wish some other screenshots as well?
I have in my OnStart cutscene a Player: Constrain action, with move path set to IslandPath and Can reverse along path? is ticked.
Pathfinding is set to Unity Navigation. movement method is Direct, Input keyboard or controller, Direct-movement type Relative to Camera, Movement limitation: No Limit.
My AC version is 1.73.8, and I'm using Unity 2019.3.0f6
Do you wish to see other screenshots as well? Of what should I provide them?