Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

The object?.function() is working like a 

if(object != null) object.function();

So, it is a short form to avoid null exceptions. Esp helpful when you are unsure is something is initialized and it's not really important that it happens. But it's still a null check so it's better to avoid it if it can be avoided. 

Another suggestion I would give you is to work more with [Serializedfield] instead of searching for components. The component search is very time-consuming. If you need to search for a component, try to avoid doing it in Update and if possible, cache it in a local variable in Start or Awake. I know it's not possible in all cases.

I tried to look for the stuck issue. But I could not figure it out... it might be fixed with the two ground detectors, at least you should be able to jump in that case. I think it was partly related to the fact that you were half off the platform.

(1 edit)

Yeah, I'm hoping getting stuck issue would be resolved by your fix. After thinking about it I suspect it might be related to a situation in which the character is physically colliding with the platform but the ground check claims the character to be on air applying constant downward velocity to the character which might then hinder sidewise movement.

Thanks for the explanation! It makes sense and will totally be useful to remember in the future. So would FindObjectOfType<Player>()?.transform then return null in case the object is not found?

About using FindObjects and GetComponents... I was prioritizing code writing speed over code execution speed because I had very limited time to work with the jam project. I know that they are slow but I believed this to be small scaled enough project that it wouldn't affect performance too much.

By the way, you did not answer to my last question about how would it be okay to mention you as special thanks in the game credits (and would you prefer your username or some other name to be used)?

(+1)

Oops... I missed the last part. Sure, Vendolis is the internet name that I generally use. Thanks a lot.

Yes "Transform transform = FindObjectOfType<Player>()?.transform" would result in null to be assigned and the .transform not to be executed. It is basically like the lines ends before the "?". 

And yes... yes I totally understand that time is an essential part of a Jam. I don't think anyone's code looks clean here.