Objects Stuck in Collision for Key, Mouse, and Touch Control (SOLVED)

Block keeps getting stuck in collision with Arrows, so CarParts stops moving.

I’m trying to keep Block from getting permanently stuck so CarParts can move left or right. The “Move A away from B” action usually does the trick, but not this time. Trigger Once doesn’t seem to work anywhere, either.

I’m no expert, but here’s some of my ideas:

What happens if you put trigger once under “the variable direction of carparts = still”? That seems like it might allow the car to move.

I’m also not sure about what “block” is doing. Based on context, I’m assuming it’s a hitbox for CarParts.

There might also be some weird things with hitboxes going on.

1 Like

Can you post a screenshot of the scene or maybe a short gif or a link to a video?

Are the parts only in collision with 1 arrow at a time?

The seperate objects action might not be pushing the objects far enough. It pushes the objects just enough that they don’t overlap but they could still trigger the collision condition.

You could try setting the collision condition option ignore objects that are touching to yes.

You could also seperate the objects a little more by saving the location of the object before it’s seperated in variables and then after the seperate action calculate the angle between the original position and the current position. Then add a little instant force. This would work for 1 object. If there could be multiple objects in collision then you would need to use for each instance first.

Something like:

I was using a button just for testing.

I was playing around with this. This would work if multiple parts could be in collision at the same time.

You would use 2 collision conditions because the first collision would pick all the parts and arrows that were in collision. While the 2nd collision condition would pick only the arrow that the specific part was in collision with.

I believe he want to simulate a knockback on the box while the car bump on it but keep moving.
Imo i guess he just need to check the collision one time and put a force on both objects at contact in the opposite directions…
but imo: if the force of the bump is greater than the car speed it should stop the car

1 Like

I tried that, but sadly the objects didn’t stop when they collided.

It seems like I misunderstood the problem.

In that case then I would recommend using forces as @Keith_1357 was showing.

1 Like

I made this thread last night when I was really tired and I forgot to take a screenshot of the scene. I wanted to try a first person perspective with a game, this one is inside a car.

The idea I wanted to try was that, when the arrow buttons collide with the orange blocks, they stop so the camera doesn’t go out of bounds. Another game I made worked with this type of coding, so I thought I could try it again with this game. This one seems to be glitching, however

Good news and bad news

Good news is that I was able to use your guy’s suggestions and I was able to make it so that, with PC controls, the collisions don’t get stuck, anymore. I had to look at which object were in the designated groups and separate the mouse/touch controls with the key controls.

The bad news is that I’m still figuring out how to make the mouse/touch controls work. When the mouse presses the buttons, the collision doesn’t register at all and the screen keeps moving, so I’ll need to figure that out.

Edit: Seems like when I use the mouse, the Block will actually move instead of staying put like with the keys, so that’s what I need to fix.

1 Like

I need to read your events more but my initial thought is the last line is setting the direction to still if no key is pressed. Would that also apply if the person was using a touchscreen? Would it always set the variable to still?

Maybe you can set the variable to still before or after the mouse and keyboard conditions. Without any conditions.

image

Like this?
This doesn’t seem to be working, so I’ll need to tinker with it a little bit more

You might need to replace the inverted on arrows with a NOT condition and a non-inverted on arrows.

If you multiple instances then the cursor will most always not be on one of the arrows.

Event then, you might want to check the touch mode or mouse is down.

Like this?
This isn’t working, either.

I should mention that I’m recovering from a cold today, so I’m gonna be a bit slow.

EDIT: Actually, maybe the block does stop, it’s just CarParts that keep moving. Maybe if I can fix that, then the mechanic will be complete.

EDIT 2: I don’t think what I’m doing is possible and I’m not sure how I can get what I’m trying to do to work.

I’m not sure if this is the issue. I don’t think the key condition needs to be inside the NOT just the cursor.

Invert the key
Not
… Mouse

That’s okay. I think I figured out the main issue. Basically I’m looking at objects like CarPartds as a sprite when I should really be looking at it as parts of the background. Which means I should approach the process with camera control instead.

Currently working on this path.

1 Like

Okay, I finally got something I can work with. The programming isn’t finished as I want to make the ability to choose whether to use keys or mouse and touch as an option for the public build, but what I got is functional.

Very important: I added some camera boundaries, which helps keep the mouse controls from moving everything off the screen. That’s what mainly solved my problem.

I’m gonna redo the thread’s title

I’m gonna go destress with Silksong, now