Powered by Invision Power Board

 
    Reply to this topicStart new topicStart Poll

> Need help with GML collision code
United States
Tek
Posted: Apr 5 2009, 10:55 PM
Quote Post


no
[*]

Group Icon
Group: Members
Posts: 4393
Member No.: 1734
Joined: 17-December 05

Status: (0d) [--]


I'm having a bit of trouble with this code. It works fine, except when you try to jump while moving into a wall. It doesn't let you jump.
Code for collision with wall/floor/ceiling object:
CODE
if place_meeting(x,y+abs(vspeed),block)
   {
   move_contact_all(270,8.5)
   vspeed = 0
   if jumpindex != "crouch"
   jumpindex = "stand"
   }
if place_meeting(x,y-abs(vspeed),block)
   {
   move_contact_all(90,8.5)
   vspeed = 0
   }
if place_meeting(x+hspeed,y,block)
   {
   move_contact_all(direction,5)
   hspeed = 0
   }

I'm using just one object as the wall, floor, and ceiling. The jumpindex bit isn't important- that just stops you from getting out of crouch mode when you're on the ground

This post has been edited by Tek on Apr 5 2009, 11:02 PM


--------------------
PMEmail PosterUsers Website
Top
Qatar
Keyser Soze
Posted: Apr 5 2009, 11:40 PM
Quote Post


The Lights are Going Off
[*][*][*]

Group Icon
Group: Members
Posts: 4673
Member No.: 3299
Joined: 13-February 07

Status: (0d) [--]


Your movement system uses the x+ technique and not vspeed= correct?


--------------------
QUOTE (
Raie @ Sep 18 2009, 08:55 PM)
Keyser you're the best person ever.
PMEmail PosterYahooMSN
Top
United States
Tek
Posted: Apr 6 2009, 06:38 AM
Quote Post


no
[*]

Group Icon
Group: Members
Posts: 4393
Member No.: 1734
Joined: 17-December 05

Status: (0d) [--]


QUOTE (Keyser Soze @ Apr 5 2009, 09:40 PM)
Your movement system uses the x+ technique and not vspeed= correct?

You mean hspeed? That's what it uses.


--------------------
PMEmail PosterUsers Website
Top
United States
OniLink10
Posted: Apr 6 2009, 09:49 AM
Quote Post


C++ Programmer, Unofficial Physicist, and Unofficial Chemist
[*][*]

Group Icon
Group: Members
Posts: 3920
Member No.: 4907
Joined: 19-February 08

Status: (0d) [--]


QUOTE (Tek @ Apr 6 2009, 04:38 AM)
You mean hspeed? That's what it uses.

Avoid hspeed and vspeed, they are very glitchy.


--------------------
QUOTE (Xgoff @ Sep 10 2009 @ 06:11 PM)
did you try hello's engine

make sure to not ****ing change anything before using it!
PMEmail PosterUsers WebsiteYahoo
Top
Unspecified
Morshu McPhereson
Posted: Apr 6 2009, 07:09 PM
Quote Post


Who's got the sweetest disposition?
[*]

Group Icon
Group: Members
Posts: 20184
Member No.: 685
Joined: 23-November 04

Status: (0d) [--]


QUOTE (OniLink10 @ Apr 6 2009, 09:49 AM)
Avoid hspeed and vspeed, they are very glitchy.

I must be on crack because I use jumping to move horizontally but speed to move vertically. As for your problem Tek, I would put something along the lines of this in your step event:

CODE
if place_meeting(x+hspeed*2,y,block) then hspeed=0


That's probably not the best method but it's what I do. The flaw with this is that he'll stop a little early. I'd try to think of a better way but I'm not familiar with your engine.
PMEmail Poster
Top
United States
Tek
Posted: Apr 6 2009, 09:33 PM
Quote Post


no
[*]

Group Icon
Group: Members
Posts: 4393
Member No.: 1734
Joined: 17-December 05

Status: (0d) [--]


Thanks Mason, that code worked well enough. I'll use it for now, but the fact that your code worked suggests that the player is simply too close to the wall when jumping, so I might be able to work a fix off of that info. Again thanks for your help!


--------------------
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

  Topic Options Topic Options Reply to this topicStart new topicStart Poll

 




[ Script Execution time: 0.0473 ]   [ 14 queries used ]   [ GZIP Enabled ]   [ Server Load: 1.24 ]