• Ever wanted an RSS feed of all your favorite gaming news sites? Go check out our new Gaming Headlines feed! Read more about it here.
Status
Not open for further replies.

Mike Armbrust

Member
Oct 25, 2017
528
Getting back into the mojo of sharing things, I've mostly finalized my continent generation.



The system produces really good height maps in my opinion but I'm a bit stumped when it comes to close up details.

cy9QjO2.png


For example I'm attempting to have waves that crash up against the land. I can use the water depth to create a distance function from the shore (shown here) but the resolution is too low to have smooth movement. I think I might have to make actual wave objects that spawn in when the camera gets close enough, kinda like waves in Civilization 6. Would look good but would use up a lot of my rendering budget if thousands are on screen.

EDT: work in progress waves.



Exclusively done in the water shader which makes it work for the entire map by default. Not sure if this is the best method but it at least works.
 
Last edited:

Sean Noonan

Lead Level Designer at Splash Damage
Verified
Oct 26, 2017
384
UK
I'm getting so much more comfortable with 3D now. I still hate unwrapping though :p

 

Benz On Dubz

Member
Oct 27, 2017
763
Massachusetts


I should be able to finish the gameplay within the next month, but I still need music, UI, environments, fx, rig for 3rd character, and some simple cutscene anims.

So much work for such a simple game!
 

Mike Armbrust

Member
Oct 25, 2017
528

First the good news.

Technically everything is progressing great. This video shows the massive scale of the game and support for high quality effects up close. I'm using a two camera system similar to Kerbal Space Program and other space games. One camera renders the background and then the other renders close up geometry on top of it. You can clearly see this effect when the camera zooms in and out since the detail terrain is darker.

The second half of the video really shows just how seamless the camera overlap effect is. At worst players will just think of it like regular LOD. Double precision is used to keep things smooth. Before setting up this method, the meshes and camera jittered near the center and essentially broke near the world edges.


Now the bad news.

I don't know what the heck this game is supposed to be. It started as a niche sequel to a 2D/text based RPG I made for my website, but the switch to 3D graphics has really elevated everything. The world is over 1,000,000 square kilometers in area and my original spreadsheet style gameplay feels out of place. I'm going to cut a large chunk of features so I can make the rest higher quality, but I'm not sure what to remove. I might remove this zoom in stuff completely and focus on kingdom building haha.
 

Chronus

Member
Nov 2, 2017
457
I recently started a new little hobby project, and it's the first time I'm making a big-ish game by myself. And more than anything else - What's killing me is the doubt over every single decision. Even when I finally nail down on a spec, I'll keep doubting it as I move forward and built on top of it and then I just feel unsure of the whole thing :(
How do you guys deal with these blocks? Is there something that makes committing to a decision easier for you?

An if any of you are fans of dungeon crawlers and want to help me out - The trigger here is that I'm wrecking my brain over using grid-based or free movement in my blobber-inspired dungeon crawling RPG.

I know it's been a while, but I'll give you my 2 cents. I had never played a tile based dungeon crawler till I tried Legend of Grimrock, but I loved it and have been a fan ever since. Granted, I started off on a great game and, sure, it does seem to make combat a bit weird (coming mostly from FPSs, I found this a bit strange to adjust to at the beginning).
I tried a few free roaming games after and it didn't click as well for me.
I guess they also lead to a different kind of puzzle possibilities and all that too.
Anyway, why not go for what you feel you'd want to play? Not much fun making a game if you don't enjoy it.
 

dude

Member
Oct 25, 2017
4,634
Tel Aviv
I know it's been a while, but I'll give you my 2 cents. I had never played a tile based dungeon crawler till I tried Legend of Grimrock, but I loved it and have been a fan ever since. Granted, I started off on a great game and, sure, it does seem to make combat a bit weird (coming mostly from FPSs, I found this a bit strange to adjust to at the beginning).
I tried a few free roaming games after and it didn't click as well for me.
I guess they also lead to a different kind of puzzle possibilities and all that too.
Anyway, why not go for what you feel you'd want to play? Not much fun making a game if you don't enjoy it.
Thanks! It's actually still relevant lol so input was very much appreciated.
My initial issue was that I like both ways, and couldn't decide which one would be a better fit for the game. But since then, I started feeling like grid-based is the best choice for this game, so I'm working on switching to it right now. Worst case scenario, I can go back to free-form movement. I just have to figure which one I like more soon so that I can start building a lot of the other systems like combat etc.
 

Benz On Dubz

Member
Oct 27, 2017
763
Massachusetts

First the good news.

Technically everything is progressing great. This video shows the massive scale of the game and support for high quality effects up close. I'm using a two camera system similar to Kerbal Space Program and other space games. One camera renders the background and then the other renders close up geometry on top of it. You can clearly see this effect when the camera zooms in and out since the detail terrain is darker.

The second half of the video really shows just how seamless the camera overlap effect is. At worst players will just think of it like regular LOD. Double precision is used to keep things smooth. Before setting up this method, the meshes and camera jittered near the center and essentially broke near the world edges.


Now the bad news.

I don't know what the heck this game is supposed to be. It started as a niche sequel to a 2D/text based RPG I made for my website, but the switch to 3D graphics has really elevated everything. The world is over 1,000,000 square kilometers in area and my original spreadsheet style gameplay feels out of place. I'm going to cut a large chunk of features so I can make the rest higher quality, but I'm not sure what to remove. I might remove this zoom in stuff completely and focus on kingdom building haha.

Haha! That's awesome! Well done.

Do you run into any floating pt issues when the camera is far from the origin (jittery camera, z fighting, etc).
 

Mike Armbrust

Member
Oct 25, 2017
528
Haha! That's awesome! Well done.

Do you run into any floating pt issues when the camera is far from the origin (jittery camera, z fighting, etc).
Thank you!

Originally I had a lot of floating point issues but the new system solves that. Small detail objects like people are always relatively close to the origin and are scaled up during rendering. Double precision floats are more than enough to handle my stuff behind the scenes.
 

Benz On Dubz

Member
Oct 27, 2017
763
Massachusetts
Thank you!

Originally I had a lot of floating point issues but the new system solves that. Small detail objects like people are always relatively close to the origin and are scaled up during rendering. Double precision floats are more than enough to handle my stuff behind the scenes.

Word. I had a similar issue due with floating pt precision for a while. I ended up scaling everything down. Hopefully, it'll be enough as I don't want to futz with it anymore!
 

FrakEarth

Member
Oct 25, 2017
3,273
Liverpool, UK
Although I code sites and apps for a living, I've never really tried to make anything gamey.. I mess around with blender from time to time doing stuff like this



I've had a play around with unity and unreal, and I've seen some cool stuff on game salad.. so I know there are pretty awesome tools but for whatever reason I've always had that starter hurdle and never been able to just 'start' trying to make something...

I was in Arcade Club in Bury (in the UK) at the weekend and I really liked playing some of the old vector display games like Asteroids, Star Castle and Tempest.. I still feel like they look quite good, high resolution in a lo-fi vectory sort of way. I think I've always liked them really and it's part of why I liked stuff like geometry wars...



So anyway, something just clicked and I thought implementing an old game idea might be a fun way to get started so I opened vscode and started trying to build Asteroids. I figured I could maybe build on top of it and add some of my own nonsense if I have time.

I didn't wanna use any existing libraries, and although I work with C# and TypeScript, I wanted to keep it simple so it's just JavaScript and HTML canvas, with the game loop class running a setInterval for the main game loop.

Objects like the asteroids and the player ship have an internal "path" variable (an array of 2d canvas context instructions like moveTo, lineTo etc) which defines the shape of the object relative to the objects' local origin. In the case of the ship, player input affects things like thrust velocity and rotation, rotation applies a transform on the path coordinates immediately, and the direction / thrust is used to update the position on each draw-call. The asteroids are simpler and just have a rate of spin, direction and velocity. When randomly instantiated I decided to make the asteroids initial direction be a straight line to the player.

Each asteroid is made up of 5-8 randomly generated points from the center, with the range of possible points being limited differently depending on the type of asteroid (big one that divides on impact or small one that is simply destroyed).

I originally had the ship moving along a vector up to a maximum speed whenever I pressed up, but it drove like a car and wasn't right at all. I then realised I needed to simulate thrust and maintain that separately from rotation / direction. I apply some easing to the acceleration / deceleration.

I added a starfield, which is done by breaking the canvas up in to an 8x8 grid and generating a few random stars for each square, each star in the list is basically x, y and depth - I use the X and Y to plot the star, and I move them in the opposite direction of the ship's movement, I scale the movement depending on the depth variable which gives the illusion of, well, depth...



Collision detection has been a bit of a ball ache having never done it before. Because all objects have a path that rotates, the shape is rarely consistent and being 'hollow' I can't do a pixel check... So I've given each object class a method which returns a bounding box for the rotated path which I can then use to detect crude / rough collisions. I can toggle drawing of the bounding boxes for debugging..

If the ship is fully inside an asteroids bounding box on a draw-call, I call that a hit, if the boxes overlap only slightly I then check for intersections on the line segments of the ship and the target asteroid so that the collision is a bit more accurate... For shooting I just do the bounding check as that mostly feels good enough. I've not added explosions or ship/player-death just yet..

On the subject of the collisions, I made a mistake earlier tonight where I implemented asteroids splitting in two, but a) forgot to dispose the bullet that caused it, b) forgot to remove the asteroid that split, and c) forgot to ensure only mini asteroids would be generated. The result is a lag inducing chain reaction



I've fixed that now...

This might all be super simple for those of you frequenting the thread, but I've really enjoyed mucking about with it and thought I'd share... it's given me some encouragement to maybe try more and certainly build on this at least..

My code needs some serious cleanup as the classes weren't properly planned but I can try and throw it up on git if anyone's interested.

i briefly toyed with the idea of making it Battlestar Galactica themed.. making the ship a viper and adding cylon raiders etc :)
 
Last edited:

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
Although I code sites and apps for a living, I've never really tried to make anything gamey.. I mess around with blender from time to time doing stuff like this



I've had a play around with unity and unreal, and I've seen some cool stuff on game salad.. so I know there are pretty awesome tools but for whatever reason I've always had that starter hurdle and never been able to just 'start' trying to make something...

I was in Arcade Club in Bury (in the UK) at the weekend and I really liked playing some of the old vector display games like Asteroids, Star Castle and Tempest.. I still feel like they look quite good, high resolution in a lo-fi vectory sort of way. I think I've always liked them really and it's part of why I liked stuff like geometry wars...



So anyway, something just clicked and I thought implementing an old game idea might be a fun way to get started so I opened vscode and started trying to build Asteroids. I figured I could maybe build on top of it and add some of my own nonsense if I have time.

I didn't wanna use any existing libraries, and although I work with C# and TypeScript, I wanted to keep it simple so it's just JavaScript and HTML canvas, with the game loop class running a setInterval for the main game loop.

Objects like the asteroids and the player ship have an internal "path" variable (an array of 2d canvas context instructions pretty much) which defines the shape of the object relative to the objects' local origin, and is used to draw it relative to the objects position on each draw-call.

In the case of asteroids, each one is made up of 5-8 randomly generated points from the center, with a limited range for the big and small asteroids.

I originally had the ship moving along a vector up to a maximum speed whenever I pressed up, but it drove like a car and wasn't right at all. I then realised I needed to simulate thrust and maintain that separately from rotation / direction. I apply some easing to the acceleration / deceleration.

I added a starfield, which is done by breaking the canvas up in to an 8x8 grid and generating a few random stars for each square, each star in the list is basically x, y and depth - I use the X and Y to plot the star, and I move them in the opposite direction of the ship's movement, I scale the movement depending on the depth variable which gives the illusion of, well, depth...



Collision detection has been a bit of a ball ache having never done it before. Because all objects have a path that rotates, the shape is rarely consistent and being 'hollow' I can't do a pixel check... So I've given each object class a method which returns a bounding box for the rotated path which I can then use to detect crude / rough collisions. I can toggle drawing of the bounding boxes for debugging..

If the ship is fully inside an asteroids bounding box on a draw-call, I call that a hit, if the boxes overlap only slightly I then check for intersections on the line segments of the ship and the target asteroid so that the collision is a bit more accurate... For shooting I just do the bounding check as that mostly feels good enough. I've not added explosions or ship/player-death just yet..

On the subject of th collisions, I made a mistake earlier tonight where I implemented asteroids splitting in two, but a) forgot to dispose the bullet that caused it, b) forgot to remove the asteroid that split, and c) forgot to ensure only mini asteroids would be generated. The result is a lag inducing chain reaction



I've fixed that now but don't have a recording...

This might all be super simple for those of you frequenting the thread, but I've really enjoyed mucking about with it and thought I'd share, it's given me some encouragement to maybe do more and certainly build on this a little more..

My code needs some serious cleanup as the classes weren't properly planned but I can try and throw it up on git if anyone's interested.

i briefly toyed with the idea of making it Battlestar Galactica themed.. making the ship a viper and adding cylon raiders etc :)


It's always super charming and evocative when someone else falls down the deep, dark, inescapable pit that is indiedev addiction discovers the wonderful world of videogame development. It's so engrossing to work with the most basic tools and do everything from scratch yourself, so just have fun. You can always switch to a game development environment later on if you want.

As for the collisions, I wouldn't go for anything more complicated than a box or a circle, it's nearly indistinguishable for the player. I would go for circles in your case since the asterods are kind of round; you can simply measure distance between centers and check if it's smaller than the sum of both radii (small performance tip: it's more efficient if you just compare squared distances, as that way you don't need to use square roots). So, something like:
collision = ((shipPox.x - asteroidPos.x) * (shipPox.y - asteroidPos.y)) < ((shipRadius + asteroidRadius) ^2)
 

FrakEarth

Member
Oct 25, 2017
3,273
Liverpool, UK
It's always super charming and evocative when someone else falls down the deep, dark, inescapable pit that is indiedev addiction discovers the wonderful world of videogame development. It's so engrossing to work with the most basic tools and do everything from scratch yourself, so just have fun. You can always switch to a game development environment later on if you want.

As for the collisions, I wouldn't go for anything more complicated than a box or a circle, it's nearly indistinguishable for the player. I would go for circles in your case since the asterods are kind of round; you can simply measure distance between centers and check if it's smaller than the sum of both radii (small performance tip: it's more efficient if you just compare squared distances, as that way you don't need to use square roots). So, something like:
collision = ((shipPox.x - asteroidPos.x) * (shipPox.y - asteroidPos.y)) < ((shipRadius + asteroidRadius) ^2)

That's so much neater and looks so much more performant than what I've actually done 😆

But that's why I'm here.. thank you for that, I didn't consider bounding circles - it'd make enough sense even for the misshapen ones..

Do you have any recommendations regarding bounce? I'd like to have the asteroids bounce off one another (and maybe break down while they do), but not too sure on the math... I was thinking it would be either something simple like invert both vectors, or maybe find the normals or do some kind of product calculation to send them veering off in a more natural feeling direction.

I'm amazed that people programmed games like this in 1979 using processor instructions or whatever... It's actually mental.
 

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
That's so much neater and looks so much more performant than what I've actually done 😆

But that's why I'm here.. thank you for that, I didn't consider bounding circles - it'd make enough sense even for the misshapen ones..

Do you have any recommendations regarding bounce? I'd like to have the asteroids bounce off one another (and maybe break down while they do), but not too sure on the math... I was thinking it would be either something simple like invert both vectors, or maybe find the normals or do some kind of product calculation to send them veering off in a more natural feeling direction.

I'm amazed that people programmed games like this in 1979 using processor instructions or whatever... It's actually mental.

Bouncing can be pretty simple or pretty complicated depending on how accurate you want it to be. Since your objects can be assumed to have almost zero elasticity, a super simple initial approach could be to just swap velocities between the two colliding objects and call it a day (don't flip any signs or anything, just directly swap them as is). This should look decent enough on many collisions, except perhaps "grazing" ones where the relative direction of movement is almost paralel to the plane of contact. Still, I'd give it a try and see how that looks. :)
 
Jan 9, 2018
4,390
Sweden
Although I code sites and apps for a living, I've never really tried to make anything gamey.. I mess around with blender from time to time doing stuff like this



I did something similar, but I used Magicavoxel to model it and then animate it in Blender.

0001-0099.gif


I haven't used Magicavoxel a lot, but it seems to be a bit cumbersome doing that kind of stuff in Blender. If you're doing voxel art specifically I'd recommend you check it out. It's pretty neat.




This is beautiful and hypnotic to watch. :)

Thank you! :3
 
Last edited:

Benz On Dubz

Member
Oct 27, 2017
763
Massachusetts


I fixed my anim event code yesterday to handle looping animations. The video above has anim events for each foot to spawn the snow foot prints.

I find animation coding to be incredibly difficult!
 
Last edited:

Mike Armbrust

Member
Oct 25, 2017
528


I fixed my anim event code yesterday to handle looping animations. The video above has anim events for each foot to spawn the snow foot prints.

I find animation coding to be incredibly difficult!


I've just started down the path of learning animations. It's something I've been avoiding for years haha.

Your footprints look nice and really help sell the snowman character.
 

Benz On Dubz

Member
Oct 27, 2017
763
Massachusetts
I've just started down the path of learning animations. It's something I've been avoiding for years haha.

Your footprints look nice and really help sell the snowman character.

Thanks!

The foot prints are projected decals which are rendered as a cube. Anything within the cube gets the decal drawn on automatically.

The system can distinguish between characters and environments, but the footprints currently don't have that flag set. If you look closely you can see the snow prints drawing on snolaf's foot!
 
Oct 27, 2017
6,467
Hi guys, I've hit a small roadblock and i don't know what's causing it. I'm making this flappy bird clone tutorial as an introduction to Unity.

https://youtu.be/A-GkNM8M5p8?t=4085

I'm here in the tutorial and I did everything he did the exact same way in the GameManager script (and I have no typos but I'll go back and look to be sure) but when he adds the GameManager as a Main Camera component, he has Start Page, Game Over Page, and countdown page in white under the greyed out GameManager on the right. Mine only has the greyed out Game Manager and nothing to drag and drop the UI elements into on the right like he does in the tutorial. Can anyone help me?

https://drive.google.com/open?id=14bLzj3d1QAvqtHHp9prb1mdSvk00cj8s

EDIT: Can I just drag and drop the GameManager into those pages on the canvas and get the same effect as what he is doing on the Main Camera? Otherwise i need to know how to do that but my unity isn't doing the same thing.
 
Last edited:

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
Hi guys, I've hit a small roadblock and i don't know what's causing it. I'm making this flappy bird clone tutorial as an introduction to Unity.

https://youtu.be/A-GkNM8M5p8?t=4085

I'm here in the tutorial and I did everything he did the exact same way in the GameManager script (and I have no typos but I'll go back and look to be sure) but when he adds the GameManager as a Main Camera component, he has Start Page, Game Over Page, and countdown page in white under the greyed out GameManager on the right. Mine only has the greyed out Game Manager and nothing to drag and drop the UI elements into on the right like he does in the tutorial. Can anyone help me?

https://drive.google.com/open?id=14bLzj3d1QAvqtHHp9prb1mdSvk00cj8s

From a quick glance it seems like you should indeed be getting the three public fields, so it's likely that the cause is something else. Sorry if these seem stupid, but sometimes problems have the simplest causes imaginable (happens to me at least once a day), especially if you're new to Unity:
- Is the project actually compiling correctly? Check the log / console (should be a tab on Unity) for compile errors. If there's a compile error, even in another script, the whole project will instead use the last "working" compile, which may not include these fields.
- Is the GameManager component expanded? Like a folder in a file explorer, each components (script) has a little triangle that you can click to show or hide everything within that component.

If none of these is the issue, feel free to upload the entire project folder and I'll have a look at it.
 

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
https://drive.google.com/open?id=1P5KBpb4roEkZH75FfaG5wNoeQl3WceYF <--Tap Controller text.

https://drive.google.com/open?id=1TFLgc0KPTwoX9kxuoGR0VamnxvMonL8e <--Errors it has shown me.

But I did the tap controller the exact same way he did it, so I don't really see what I did wrong. if this doesn't help I'll upload the whole project and let you take a look at it.

The log made it easier to spot the issue; it says that GameManager.PageState has no definition for GameOver. This is how you have defined PageState:

enum PageState {
None,
Start,
Gameover,
Countdown
}

Spot the typo?
It should be GameOver, not Gameover. :)
 
Oct 27, 2017
6,467
The log made it easier to spot the issue; it says that GameManager.PageState has no definition for GameOver. This is how you have defined PageState:

enum PageState {
None,
Start,
Gameover,
Countdown
}

Spot the typo?
It should be GameOver, not Gameover. :)
damn, such a small thing, too. like you said.

Shit, well that was all it was, damn. Working like a charm now. Thanks a lot.
 
Oct 27, 2017
6,467
Very glad to be of service! It's always the smallest, dumbest things, isn't it? :D
Yes, and I've ran into another problem sadly.


I don't get errors, either. it just isn't doing it correctly. i can press my play and restart buttons but it hangs after pressing play.


EDIT: Never mind, I got the problem. I didn't add the countdown component to the countdown page in unity itself. But still having a slight problem now. First is that my bird always faces downwards after restart even after i did his script that made his face forwards on restart. not a huge issue because can still play it, but it is aesthetically unpleasing. So still an error. Also the countdown plays when first starting the game and not just on replay. so that is annoying too, but can maybe wait till i get through the rest of the tutorial to fix it. anyways I'm taking a break for now. need a nap.
 
Last edited:

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
Yes, and I've ran into another problem sadly.


I don't get errors, either. it just isn't doing it correctly. i can press my play and restart buttons but it hangs after pressing play.


EDIT: Never mind, I got the problem. I didn't add the countdown component to the countdown page in unity itself. But still having a slight problem now. First is that my bird always faces downwards after restart even after i did his script that made his face forwards on restart. not a huge issue because can still play it, but it is aesthetically unpleasing. So still an error. Also the countdown plays when first starting the game and not just on replay. so that is annoying too, but can maybe wait till i get through the rest of the tutorial to fix it. anyways I'm taking a break for now. need a nap.

If you still have any errors when you complete the tutorial, be sure to upload the whole project folder, not just the code, and I'll see if I can help (although I'm leaving the 3rd on vacation).
 

Aurelioking

Member
Oct 28, 2017
61
This might not be the thread for this but does anybody have experience with the Playable API in Unity?
I'm having some problems with it and i think that the core issue is that i don't fully get what it is for.

I'm working on a small 2D game with a relatively low number of animations, initially i was using an Animator component to handle animation transitions but i recently refactored my Player script to work like a Class based finite state machine and found that having two "parallel" fsm (Animator and the Player code) was kind of a mess to "synchronize".

So i looked into an easier and more direct way to play animations via code and stumbled upon the legacy animation system and then the Playable API and the PlayableGraph which if i understand correctly can do anything the legacy system did plus more (Playable API documentation).

Now let's say that i want to play an animation when the player enters a certain state, what is the correct approach?
  • If i only want to play an animation this seems like the easiest way to do it:
    AnimationPlayableUtilities.PlayClip(GetComponent<Animator>(), clip, out playableGraph);(source)
  • If i want to play an animation and also a sound i start to get lost:
    • Do i put the animation and the sound in the same graph like in the Creating a PlayableGraph with several outputs example? By default the animation and sound start at the same moment.
    • Do i put the animation and sound clip in different graphs and play them separately?
    • What if i want the sound to play at a specific frame of the animation? Do i have to use animation events?
    • What if i want to execute a piece of code at a specific frame of animation?
side-note:
Does anybody use Unity on Ubuntu 18.04? Windows sometimes freezes on me and i would like to move to Ubuntu, would it be a painless transition? I use VScode to write code.
 

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
This might not be the thread for this but does anybody have experience with the Playable API in Unity?
I'm having some problems with it and i think that the core issue is that i don't fully get what it is for.

I'm working on a small 2D game with a relatively low number of animations, initially i was using an Animator component to handle animation transitions but i recently refactored my Player script to work like a Class based finite state machine and found that having two "parallel" fsm (Animator and the Player code) was kind of a mess to "synchronize".

So i looked into an easier and more direct way to play animations via code and stumbled upon the legacy animation system and then the Playable API and the PlayableGraph which if i understand correctly can do anything the legacy system did plus more (Playable API documentation).

Now let's say that i want to play an animation when the player enters a certain state, what is the correct approach?
  • If i only want to play an animation this seems like the easiest way to do it:
    AnimationPlayableUtilities.PlayClip(GetComponent<Animator>(), clip, out playableGraph);(source)
  • If i want to play an animation and also a sound i start to get lost:
    • Do i put the animation and the sound in the same graph like in the Creating a PlayableGraph with several outputs example? By default the animation and sound start at the same moment.
    • Do i put the animation and sound clip in different graphs and play them separately?
    • What if i want the sound to play at a specific frame of the animation? Do i have to use animation events?
    • What if i want to execute a piece of code at a specific frame of animation?
side-note:
Does anybody use Unity on Ubuntu 18.04? Windows sometimes freezes on me and i would like to move to Ubuntu, would it be a painless transition? I use VScode to write code.

I've also been trying to coerce the Playables library to do what I want for quite a while, with mixed results. I'm using a hybrid approach where I still use standard animators for generic actions (movement, etc.) while using ad-hoc constructed playable graphs (which is what PlayClip does) for things like attacks. Regarding sound, I don't try to leverage that part of the playables library for it, but rather play them on my own (either at the same time the animation starts, or via events, like you say). I do this for several reasons; one of them is that I have a custom sound manager that avoids things like the same clip playing multiple times during the same frame (which, because of how waveforms work, results in the clip playing at a disproportionately high volume), and also handles directional sound and doppler effect.

Unfortunately this hybrid approach has come with quite a few issues. For one, there's no easy way to know when the animation has ended (to disconnect and destroy the graph and let the animator resume normal operation). I'm currently using such an embarrassingly hacky approach as measuring the animation length adjust it by the animator play speed, and pretty much wait that long (it's a bit more complicated as the animator speed can actually change mid-animation due to being underwater, etc. but that's the basic idea).

This works pretty well, but there's another issue in that forcing the animator to play an animation on top of the already running animator (which BTW you need to stop; even if you're not actually seeing its effects, it will keep running in the background and fire events) doesn't always sit well with Unity. In particular there's a... bug? behaviour? where when the animation ends, some values (typical example is collider sizes) may become "stuck" on their last value, rather than reverting to their defaults. I'm not sure what causes it, and it's hard to reproduce; I think it doesn't happen anymore, but...

Anyway, the tl;dr of the last two paragraphs is "don't do what I did if you can avoid it". It's a bit late for me to change my entire animation system, but if you intend to handle the animations 100% yourself with no animator state machine at all, you probably won't have any of these issues... probably. Frankly, I would love to hear what your results are; if you indeed have no issues when using a fully custom state machine and no animator, that would be a solid reason for me to consider biting the bullet and doing the same.
 
Oct 27, 2017
6,467

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
Weltall Zero

Sorry but having another problem and this time I don't understand it at all, lol.


I'm here in the tutorial and he has no errors but I have many of them. And like last time I have checked my work and don't see anything wrong for myself.


EDIT: Those are the up to date errors and parallaxer.cs is where most of them lie.

You have another typo: OnGameOverConfirmed -> OnGamerOverConfirmed (it's on both OnEnable and OnDisable).
 

dude

Member
Oct 25, 2017
4,634
Tel Aviv
Wooo!
14b6dad7de9c908db82d51bd3a3fd933.gif

Finally got my dungeon generating, my character moving, keyboard and on screen controls and more of the basics out of the way.
Now I need to start working on art a bit more because I can't look at these temp orange walls anymore lol.
 

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
Ah. Thanks. Double checking your own work hurts sometimes

Check the error messages themselves, they're telling you where and what the issue is. If you double click them they will open the relevant file and line (at least if you're using something like Visual Studio). Visual Studio will also underline the unknown identifier in red, which makes it obvious even as you're typing. There's a free version of VS if you want to use it (in fact Unity pretty much installs with it nowadays).



Awww. Poor things just want to hug you. :(

jc3mbrk4v52y.jpg
 

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
changed that problem and now I still have two problems.


EDIT: My biggest problem is that I'm so new I don't know what the error means sometimes. This is literally my first time coding and using unity.

The problems are in Parallaxer.OnGameOverConfirmed and Parallaxer.OnConfigure; you're using SpawnImmediate (the function) when you should be using spawnImmediate (the bool field). Highlighted in red below:
void OnGameOverConfirmed()
{
for (int i = 0; i < poolObjects.Length; i++)
{
poolObjects.Dispose();
poolObjects.transform.position = Vector3.one * 1000;
}
if (SpawnImmediate)
{
spawnImmediate();
}
}

void Configure()
{
targetAspect = targetAspectRatio.x / targetAspectRatio.y;
poolObjects = new PoolObject[poolSize];
for (int i = 0; i < poolObjects.Length; i++)
{
GameObject go = Instantiate(Prefab) as GameObject;
Transform t = go.transform;
t.SetParent(transform);
t.position = Vector3.one * 1000;
poolObjects = new PoolObject(t);
}
if (spawnImmediate)
{
SpawnImmediate();
}
}
 

Weltall Zero

Game Developer
Banned
Oct 26, 2017
19,343
Madrid
Thanks a lot. Sorry I'm so new to this. Like this is my first time using C#. I'm green as hell.

It's perfectly OK, we're all learning. The important part is that you're understanding what you're doing and why. I worry a bit that the tutorial is using relatively advanced C# concepts like delegates / events. Just following a tutorial without understanding what it's doing won't help you in the long run.

If at any time you feel like you're just following steps without really "getting" everything involved in them, you should probably go slower, or even switch to a more basic tutorial (like a c# "hello world"). Also make sure to google or wiki any concept you're unfamiliar with, like the aforementioned events.
 
Oct 27, 2017
6,467
It's perfectly OK, we're all learning. The important part is that you're understanding what you're doing and why. I worry a bit that the tutorial is using relatively advanced C# concepts like delegates / events. Just following a tutorial without understanding what it's doing won't help you in the long run.

If at any time you feel like you're just following steps without really "getting" everything involved in them, you should probably go slower, or even switch to a more basic tutorial (like a c# "hello world"). Also make sure to google or wiki any concept you're unfamiliar with, like the aforementioned events.
Thanks, yeah I am probably rushing a bit, but just wanted to get something under my belt, you know. I'll probably finish this project up and then take it slower from here.

EDIT: Weltall Zero My biggest problem is that I'll do exactly what he says and get an error where he doesn't. Like I put my pipes with the exact same variables as him using the parallaxer script and his move but mine remain stationary and i get an error that i don't understand where it's coming from. Very frustrating all things considered.
 
Last edited:

dude

Member
Oct 25, 2017
4,634
Tel Aviv
changed that problem and now I still have two problems.


EDIT: My biggest problem is that I'm so new I don't know what the error means sometimes. This is literally my first time coding and using unity.
I feel you. I'm pretty much in the same boat. I do have some scripting experience in GameMaker, but Unity is a whole other beast. I have a billion tiny mistakes in every change I do.
Regarding your code: for the future, I'd advise you to name things in a less confusing way. like "isSapwnImmediate" for the bool etc. The more I code, the more I understand how important naming is - Because in the future, you'll also have a ton of methods and variables and if you don't give them names you can understand, you won't remember what and how to do with them later.
Good luck!

I do agree with Weltall Zero - I have no idea what delegates even are, and they really shouldn't be needed for building a flappy bird clone... Maybe you can switch to a simpler tutorial. Unity has some awesome stuff in learn.unity.com (it's where I'm going whenever I want to learn a new component or system.)
 
Status
Not open for further replies.