Has anyone here gotten a 2d-platformer style game to work with AC?
So the thing is we find the functionality of cutscenes, dialogue, etc. to be something we want in our game, but we want the navigation method to be something from a custom script we created
any help is appreciated, thank you!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
On a side note -- it looks like this portion of AC is failing -- seems like I cannot import
using AC;
into my scripts -- might anyone happen to know why this may be?
Ah ignore the above -- looks like it was an issue with the .asmdef file.
For robust platforming mechanics, you'll need a separate asset / script to handle the movement - IIRC this was broadly how Lair of the Clockwork God was made.
Setting your Player's Motion control field to Manual will have AC give up control over their Transform, in favour of another asset / custom script.
For details on how to incorporate a third-party controller, see the Manual's "Custom motion controllers" chapter.
So we tried creating our own script for player movement below:
using UnityEngine;
using AC;
public class PlayerMovement : MonoBehaviour
{
public float velX = 10;
public float maxRange = 1;
public float maxHeight = 3;
public float heightMultiplier = 1.2f;
public float FallMultiplier = 1.6f;
public float flinchTimer = 2;
float flinchTimeLeft;
float timeOfFlight;
float globalGravity;
float velY;
bool toJump;
bool isJumping;
float move;
public LayerMask layerMask;
private Rigidbody2D rb;
private BoxCollider2D bc;
}
The issue is that the jump movement is not being recognized? The left and right are working fine, but we're thinking that something in AC may be overriding the velocity.
Might you happen to know why this may be / how we can change it?
I set motion control to manual just as a heads up -- but sadly it seems like it still didn't work.
I'll need to see more to attempt a recreation - can you share a screenshot of your Player's full root Inspector?
Thank you!
@ChrisIceBox Is this what you mean?
https://drive.google.com/file/d/1tJR4Cb1xsy5EzJiovdeacDy-c_-9GLGp/view?usp=sharing
Also on a sidenote -- would pathfinding work on something like a tileset where we only have 2 directions for the character (moving left and right)?
I wasn't sure how to place the navmesh on the tiles so that only the top-parts are walkable.
I'm not getting any difference in the custom movement when AC's Player component is attached. Is the behaviour correct for you when you don't involve AC?
Quick note re: cutscene checking: you don't need to rely on a variable for this, you can directly read:
A custom script that limits pathfinding to the X-axis can be found here:
https://adventure-creator.fandom.com/wiki/2D_point_and_click_along_one_axis
Thanks for getting back to me -- so just to make sure I'm understanding correctly, are you saying that you are able to jump as well?
And ah yes -- without AC the behavior is fine -- we tested out a few things and and narrowed it down to the "GameEngine" gameObject that is created when initializing a scene with AC. So when this object is present, it looks like jumping is not working. However, it looks like it's needed for the dialogue to work.
Thank you so much! Just wondering -- is there a way we can generate a navmesh for a tileset map in a scene?
Thank you!
I mat not have had the right values / scale, so the jumping didn't look very natural - but it did move upward both with AC present and absent.
The GameEngine object is AC itself. What are your Unity / AC versions, and what is your Settings Manager's Movement method field set to? Try setting this to None, so that AC doesn't do anything regarding Player movement.
AC's built-in 2D pathfinding relies on Polygon Collider 2D components, while Tilemaps generate Tilemap Collider 2Ds. It may be possible to write a script that uses the shape data from one to control another. I'm not 100% but I'll take a look.
@ChrisIceBox
My movement is set to None.
Can I ask what you might have done / what your setup looks like?
Also is it possible for you to send a video of how it looks and what your hierarchy / values are?
I added the script component to a simple box sprite in the scene, added a ground sprite underneath, and used the same values as in your screenshot.
The movement was very fast and a bit jerky, but that might just be down to the scale of the sprites/scene. The key thing is that there was no difference once I used the Scene Manager to convert the scene into an AC one.
What are your AC/Unity versions?