The Daily Click ::. Forums ::. Klik Coding Help ::. Gravity/Collision Detection Problem
 

Post Reply  Post Oekaki 
 

Posted By Message

Spliffy Mc Mulligan



Registered
  13/10/2009
Points
  1
12th July, 2012 at 12/07/2012 15:09:32 -

Hey everybody, this is a great site, I`ve learned a lot about MMF, but now I am stuck and itīs driving me crazy.

Here is the problem:

I have multiple active objects (crates). Each crate has 4 collision detectors. All the crates and detectors are mere duplicates. I use the spread value command to assign each set of detectors to the right crate.
Then I test for collisions like this:

Left detector overlaps background
+ID of crate = ID of detector:
-- Set X Position of Crate to X+1


(I copy this command a couple of times to make a "fake fastloop", pushing the crate out of the background between frames)

Now, this works for the left, right and upper detector, but it doesn`t work for the ground detector because of constant gravity. All the crates have a variable "on_ground". If "on_ground=0" the crates will fall.
However, I am struggling to find a command that will accurately tell MMF when to stop applying gravity to the crates.

My idea was to position the ground detector 1 pixel below the crate, so I could do something like this:

Ground detector overlaps background
+Crate overlaps background
+ID of crate = ID of detector:
-- Set Y Position of Crate to Y+1

(As long as both crate and ground detector are in the ground: push out)

Ground detector overlaps background
+Crate DOES NOT overlap background
+ID of crate = ID of detector:
-- Set on_ground=1


(If crate is out of ground: stop pushing, stop gravity)

However, this does not work. The crates either fall through the floor or keep switching between "Falling" and "pushing out of the ground", resulting in a spastic movement. I`d be very grateful for any ideas on how to solve this problem



 
n/a

monkeytherat

Hero of Time Jr

Registered
  07/11/2010
Points
  1293

VIP MemberI donated an open source project
12th July, 2012 at 12/07/2012 16:47:55 -

I could help more if I had the file, but I do have a suggestion. Try making the detector big enough so that it overlaps your crate and replace

Ground detector overlaps background
+Crate overlaps background
+ID of crate = ID of detector:
-- Set Y Position of Crate to Y+1

Ground detector overlaps background
+Crate DOES NOT overlap background
+ID of crate = ID of detector:
-- Set on_ground=1

with

Ground detector overlaps background
+Ground detector overlaps Crate
-- Set on_ground=1

Also as a side note, adding 1 to a y coordinate will move something downwards. I hope this helped.

 
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.
The rest of them will write Perl programs.

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
12th July, 2012 at 12/07/2012 18:16:43 -

I recommend you use DavidN's platform engine to solve your issues. The main character uses invisible detectors, and it's flawless. There's no advanced stuff like climbing walls, grabbing on to edges, etc. but there are moving platforms, jump-through platforms, and springboards. It's well-commented and highly-recommended...And available at this link on the clickteam website:

http://www.clickteam.com/website/usa/img/uploads/tutorials/download/fastloop_plattutorial.zip

 
n/a

danielleblatchley



Registered
  29/09/2012 04:14:13
Points
  1
29th September, 2012 at 29/09/2012 04:26:02 -

It is a common sense that gold is very percious and now more and more people like the gold metal, and more and more people now join ge group of hunting for treasure and gold. This is like the "gold rush". But what is different form before is that now people use more advanced equippmemt to help them to find the gold. And it seems among different equippments, people like the [url=http://www.detectorall.com/categories/Gold-Metal-Detectors/]gold metal detector[/url] most, because that such a device can help them to identify the detail information of the metal so that people can find it in a short time.


 
n/a

hapsi



Registered
  13/11/2003
Points
  775
29th September, 2012 at 29/09/2012 11:21:24 -

Two words: Box 2d! It's an extension for mmf2 to create very realistic 2d physics. Easy to use.

 
[Signature][/Signature]
   

Post Reply



 



Advertisement

Worth A Click