This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-29 07:53:04

hydreigon
New Scratcher
Registered: 2011-07-20
Posts: 23

Platformer Collision Help.

Hello, I am still working on the game Steve in Space, and I request help with the main character's collision detector. The main character is a human, thus some techniques will not work. Currently I am using a technique in which when touching color orange (wall color) it will jump back to the position it was before (a variable called positionxdetector and positionydetector varifies this position) and it is very glitchy, he will sometimes get trapped in a wall. Please help.

Thanks in advance,

hydreigon

Offline

 

#2 2012-04-29 08:19:11

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Platformer Collision Help.

Hmm. The problem with using a previous position detection is that I could see it remembering the position you were in when inside the wall. Might be better to use something like if touching orange move -10 steps or whatever.

Offline

 

#3 2012-04-29 08:21:28

hydreigon
New Scratcher
Registered: 2011-07-20
Posts: 23

Re: Platformer Collision Help.

Probably, however this is a scrolling game and scrolly and scrollx are involved within it. I'll try a different method, however keep posting suggestions.

Offline

 

#4 2012-04-29 08:40:04

hydreigon
New Scratcher
Registered: 2011-07-20
Posts: 23

Re: Platformer Collision Help.

Yeah, here is the current script:

when i receive [Game Begin]
wait (0.1) secs
forever
if <touching color [orange]>
set [scrollx] to [positiontrackerx]
set [scrolly] to [positiontrackery]
end

Offline

 

#5 2012-04-29 09:02:05

hydreigon
New Scratcher
Registered: 2011-07-20
Posts: 23

Re: Platformer Collision Help.

[scratchblocks]
when  receive [game begin]
forever
if <not <touching color (orange)]>
set [positiontrackerx] to [scrollx]
set [positiontrackery] to [scrolly]
end

Offline

 

#6 2012-04-29 09:27:16

ReuleauxStudios
New Scratcher
Registered: 2012-04-29
Posts: 9

Re: Platformer Collision Help.

Hi! Try this script:

forever
  if <touching color [orange]>
    repeat until <not <touching color [orange]>>
      change [scrollx] by [-1]
    end
  end
end

Offline

 

#7 2012-04-29 09:30:54

ReuleauxStudios
New Scratcher
Registered: 2012-04-29
Posts: 9

Re: Platformer Collision Help.

You're going to have to modify my script a little.

Offline

 

#8 2012-04-29 10:05:49

hydreigon
New Scratcher
Registered: 2011-07-20
Posts: 23

Re: Platformer Collision Help.

Okay. I'm going to try and make a script in which it detects which direction you were previously facing, and if that equals a certain direction the wall will repel you in the direction you came.

Offline

 

#9 2012-04-29 10:09:35

hydreigon
New Scratcher
Registered: 2011-07-20
Posts: 23

Re: Platformer Collision Help.

Thank you ever so much ReuleauxStudios, I did modify your script a bit and indeed it works much better then my previous bump detector. You will certainly receive a shout-out in the credits.  smile

Offline

 

#10 2012-04-29 12:24:44

hydreigon
New Scratcher
Registered: 2011-07-20
Posts: 23

Re: Platformer Collision Help.

Oh wait, never mind, I am experiencing some problems. I am going to try and fix them.

Offline

 

#11 2012-04-29 12:27:38

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Platformer Collision Help.

What problems? If you post a picture, maybe I can help...


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#12 2012-04-29 12:34:30

hydreigon
New Scratcher
Registered: 2011-07-20
Posts: 23

Re: Platformer Collision Help.

I'll try and use scratchblocks to do it.

forever
if <touching color (orange)>
if <<previousdirection> = (90)>
repeat until <not <touching color (orange)>>
change (scrollx) by (3)
end
Yeah, so basically it does it like that for each previous direction (0 and -90)
Help please?

Offline

 

#13 2012-04-29 12:45:34

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Platformer Collision Help.

Can you please tell me the problem?

Oh wait, I think i've spotted it. Just change the Change Scrollx by 3 to Change Scrollx by -3.

If this is not the problem, I have a question. Can your character go/point in any direction, or just up, down, left and right?

Last edited by SciTecCf (2012-04-29 12:51:31)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

Board footer