Page 1 of 2

Reduce uesless processing in collision?

PostPosted: Wed Oct 17, 2012 12:38 am
by Hblade
What would be the most effective way to reduce the processing required for collision? I realized that most collision happens every frame, and Physical Response happening every single frame is a huge waste of processing power. So, what would be the most effective way to stop the player from falling, or hitting a wall? (I also noticed that when hitting a wall, the player kinda jumps).

Reason being is because I need to set up a template. I'm gonna make a youtube series soon and I need to set everything up properly before making the series.

Re: Reduce uesless processing in collision?

PostPosted: Wed Oct 17, 2012 5:31 pm
by Fojam
I myself just started learning C++ so that I can make my own engine from the ground up, but box collisions may be what you want to optimize your game

Re: Reduce uesless processing in collision?

PostPosted: Thu Oct 18, 2012 4:56 am
by Hblade
Thanks Fojam, but what I mean is, the collision updates every frame, and having multiple actors at the same time landing on the ground and using "Physical Response" constantly is a big processing waste. This can be avoided if physical response only has to happen once, then the gravity stops processing, or something similar but this is a problem if your walking off an edge. I've thought about CollisionFree, which I'm going to experiment with now. Sadly you'd have to have separate walls and floor actors for that to work though.

Re: Reduce uesless processing in collision?

PostPosted: Sat Oct 20, 2012 1:14 am
by Soullem
Perhaps creating a pointer, or actor under the player actor, and on collision set gravity to zero and jumps to whatever, and when collision finishes start gravity again? Ill test this out now.

Re: Reduce uesless processing in collision?

PostPosted: Sat Oct 20, 2012 5:31 pm
by Hblade
That does work but it also has some issues when you collide into the wall

Re: Reduce uesless processing in collision?

PostPosted: Sat Oct 20, 2012 6:06 pm
by Soullem
What about creating an actor to the right and left, and on collision set a varriable CanMoveRight to 0 and CanMoveLeft to 0 respectively. And on collision finish set that value to 1? Then just put the if statement (or switch) around the part of your code that moves you in that direction?

Edit: Clarity

Re: Reduce uesless processing in collision?

PostPosted: Sun Oct 21, 2012 2:16 am
by Hblade
Thats what I was originally doing, but with shorter variable names. (cml and cmr). However, this causes an issue if your going up a small ledge or trying to climb something similar to stairs

Re: Reduce uesless processing in collision?

PostPosted: Sun Oct 21, 2012 1:26 pm
by Soullem
Maybe have two clones of CanMoveRight and place one at the head and one at the feet, and then only stopwhen both are in collision? or are you using big stairs? hmmmm... Ill think on it.
You could only have one size of slopes and if the botom one colided you have an extra y-=5 to your charecter movement. Use pythagareom theroem for exact value.

Re: Reduce uesless processing in collision?

PostPosted: Mon Oct 22, 2012 7:41 am
by Hblade
To lighten things up instead of using two clone variables you can use an array of 4. int MyArray[4]

And use #define VARNAME to name the array like so

#define CMR MyArray[0]
#define CMR2 MyArray[1]

etc

Re: Reduce uesless processing in collision?

PostPosted: Thu Oct 25, 2012 12:53 am
by Soullem
I haven't had enough time to actually make anything because of school, and haven't tried it. Does it work out well? or not at all?

Re: Reduce uesless processing in collision?

PostPosted: Thu Oct 25, 2012 6:20 pm
by Hblade
Its the same as regular variables it just saves memory a bit I think or something like that

Re: Reduce uesless processing in collision?

PostPosted: Thu Oct 25, 2012 9:57 pm
by Soullem
No I understand the arrays, but is your system working out?

Re: Reduce uesless processing in collision?

PostPosted: Mon Nov 05, 2012 4:40 am
by Hblade
Oh, I haven't been working on it.

Re: Reduce uesless processing in collision?

PostPosted: Fri Nov 23, 2012 11:06 pm
by AliceXIII
the easiest way to cut out useless processing is to not process it in the first place as in if it's not needed then dont run it by far i've found programming your entire game without using a single draw event is the best use of processing power with GE, in your case i havent tried this it's off the top of my head but ie:

you have your character he has 3 movement patterns left, right, and jump in your script instead of movement with a draw event use keys may seem basic but cuts out a constant draw event left and right is self explanatory jumping though what you want to do is say you hit space and your character jumps now to apply gravity with a physical response without calling it a million times just simply use send activation event and send him gravity results while at the same time sending an activation event to your platform actor to enable collision's then when the collision's over before disabling the collision send an activation to the character to give him a gravity of 0 so when the collision's not happening he doesn't fall through the platform your only problem then would be when you walk off a platform that sits above another one and you want him to fall down onto the one below.

this could be solved by checking when your walking left and right whether an actor actually exist's in front of him then apply gravity and collisions if one doesn't!

again this is pretty theoretical of an idea right now i haven't tested it out my only problem with it is it'll possibly have some lag time in between the send activation's but i've used 1000's of actors with some precise codes in my template and i think total i only have 1 draw event in my entire template although i want it out there :)

if you dont understand or run into problems i could possibly try and make it for you!

Re: Reduce uesless processing in collision?

PostPosted: Thu Nov 29, 2012 4:37 am
by Hblade
hehe yeah, I plan on making a fun puzzle game if I can figure out things. one that wont rely on collision at all :3