Jump to content


Photo

Collision_line Problem *solved*


  • Please log in to reply
4 replies to this topic

#1 WMCD

WMCD

    Spritist

  • GMC Member
  • 1410 posts
  • Version:GM5

Posted 08 July 2009 - 02:52 AM

Okay, The enemy in my game (the red guy) uses

/*step event*/

self.cline=collision_line(self.x+8,self.y+8,obj_player.x+8,obj_player.y+
8,obj_solid,false,false)

to find if there is a wall (obj_solid) between it and the player. If it's clear, the enemy goes through with a set of charging actions, as seen below:

/*alarm 0 event*/

if self.x=obj_player.x && self.cline=false
	{
	if self.y>obj_player.y
		{
		self.step=15
		dir=2
		self.atkdir[1]=false
		self.atkdir[2]=true
		self.atkdir[3]=false
		self.atkdir[4]=false
		}
	if self.y<obj_player.y
		{
		self.step=15
		dir=4
		self.atkdir[1]=false
		self.atkdir[2]=false
		self.atkdir[3]=false
		self.atkdir[4]=true
		}
	
	}
if self.y=obj_player.y && self.cline=false
	{
	if self.x>obj_player.x
		{
		self.step=15
		dir=1
		self.atkdir[1]=true
		self.atkdir[2]=false
		self.atkdir[3]=false
		self.atkdir[4]=false
		}
	if self.x<obj_player.x
		{
		self.step=15
		dir=3
		self.atkdir[1]=false
		self.atkdir[2]=false
		self.atkdir[3]=true
		self.atkdir[4]=false
		}
	
	}

Now the code works perfect without collision_line in the mix (other than the enemy charging into walls and stopping because the player's on the other side), but when I try and use collision_line, the charge sequence isn't triggered.

Please note that I did not post all of the alarm 0 event's code, but rather just the part that's directly affected by collision_line.

Anyone have any advice on the proper use of collision_line? I'm all ears ::lmao::

Oh, and I'm working with GM6.


Thanks for your time.

Edited by Old School Gaming, 08 July 2009 - 03:14 AM.

  • 0

#2 Mnementh

Mnementh

    15151

  • Retired Staff
  • 6261 posts
  • Version:GM:Studio

Posted 08 July 2009 - 03:10 AM

The collision_* family of functions, rather than returning false when they don't find a collision, return the special object noone. So:

if self.x=obj_player.x && self.cline=noone

As a side note: you don't have to use self for local variables.

if (x == obj_player.y && cline == noone)

  • 0

#3 WMCD

WMCD

    Spritist

  • GMC Member
  • 1410 posts
  • Version:GM5

Posted 08 July 2009 - 03:13 AM

Problem solved.

Thank you mnementh ::lmao::
  • 0

#4 Mnementh

Mnementh

    15151

  • Retired Staff
  • 6261 posts
  • Version:GM:Studio

Posted 08 July 2009 - 03:15 AM

No problem. ::lmao::
  • 0

#5 Petey_Pii

Petey_Pii

    GMC Member

  • New Member
  • 769 posts

Posted 08 July 2009 - 04:04 AM

um mnementh you put if x == obj_player.y :/
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users