Reduce uesless processing in collision?

Non-platform specific questions.

Reduce uesless processing in collision?

Postby Hblade » Wed Oct 17, 2012 12:38 am

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.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Reduce uesless processing in collision?

Postby Fojam » Wed Oct 17, 2012 5:31 pm

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
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: Reduce uesless processing in collision?

Postby Hblade » Thu Oct 18, 2012 4:56 am

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.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Reduce uesless processing in collision?

Postby Soullem » Sat Oct 20, 2012 1:14 am

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.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Reduce uesless processing in collision?

Postby Hblade » Sat Oct 20, 2012 5:31 pm

That does work but it also has some issues when you collide into the wall
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Reduce uesless processing in collision?

Postby Soullem » Sat Oct 20, 2012 6:06 pm

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
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Reduce uesless processing in collision?

Postby Hblade » Sun Oct 21, 2012 2:16 am

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Reduce uesless processing in collision?

Postby Soullem » Sun Oct 21, 2012 1:26 pm

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.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Reduce uesless processing in collision?

Postby Hblade » Mon Oct 22, 2012 7:41 am

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Reduce uesless processing in collision?

Postby Soullem » Thu Oct 25, 2012 12:53 am

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?
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Reduce uesless processing in collision?

Postby Hblade » Thu Oct 25, 2012 6:20 pm

Its the same as regular variables it just saves memory a bit I think or something like that
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Reduce uesless processing in collision?

Postby Soullem » Thu Oct 25, 2012 9:57 pm

No I understand the arrays, but is your system working out?
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Reduce uesless processing in collision?

Postby Hblade » Mon Nov 05, 2012 4:40 am

Oh, I haven't been working on it.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Reduce uesless processing in collision?

Postby AliceXIII » Fri Nov 23, 2012 11:06 pm

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!
"Taking a breath of fresh air."
User avatar
AliceXIII
 
Posts: 325
Joined: Fri Sep 17, 2010 2:36 am
Location: victoria, texas
Score: 37 Give a positive score

Re: Reduce uesless processing in collision?

Postby Hblade » Thu Nov 29, 2012 4:37 am

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron