Jump to content


Photo

[3d] Have point_light follow player?


  • Please log in to reply
5 replies to this topic

#1 Hello Darren

Hello Darren

    Pirate

  • Banned Users
  • 275 posts
  • Version:Unknown

Posted 03 June 2012 - 05:01 PM

I'm making a 3d game for the first time and I couldn't find an easy way of doing a flashlight so instead I'm trying to just put a point light above the player that follows him.

I have this in the Create event which does create the light.

vLightID = floor(random(1000000));
d3d_light_define_point(vLightID,x,y,-64,128,c_white);
d3d_light_enable(vLightID,true);

I then have this in the Step event but it doesn't follow the player, instead it just stays where it originally spawns.

d3d_light_define_point(vLightID,x,y,z-64,128,c_white);


#2 kupo15

kupo15

    GMC Member

  • GMC Member
  • 400 posts

Posted 03 June 2012 - 05:15 PM

have you tried using a transformation_translation function instead?
  • 0

#3 Hello Darren

Hello Darren

    Pirate

  • Banned Users
  • 275 posts
  • Version:Unknown

Posted 03 June 2012 - 05:18 PM

No I've never heard of that function. I tried searching the help file and wiki but couldn't find anything about it.

#4 kupo15

kupo15

    GMC Member

  • GMC Member
  • 400 posts

Posted 03 June 2012 - 05:21 PM

d3d_transform_set_translation(x,y,z)
Its used to move objects so maybe it works for lighting. I haven't gotten to lighting yet
  • 0

#5 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2439 posts
  • Version:GM:Studio

Posted 03 June 2012 - 05:21 PM

vLightID = floor(random(1000000));

What's the point of this? Why a random index?
Also, GM8.1 and later only support 8 lights (indices 0 through 7), so unless you're really lucky and get a number from that interval, the light won't move (shouldn't really initialize either)
  • 0

#6 hbryantlanier@gmail.com

hbryantlanier@gmail.com

    GMC Member

  • New Member
  • 18 posts
  • Version:GM8

Posted 03 June 2012 - 05:42 PM

I'm making a 3d game for the first time and I couldn't find an easy way of doing a flashlight so instead I'm trying to just put a point light above the player that follows him.

I have this in the Create event which does create the light.

vLightID = floor(random(1000000));
d3d_light_define_point(vLightID,x,y,-64,128,c_white);
d3d_light_enable(vLightID,true);

I then have this in the Step event but it doesn't follow the player, instead it just stays where it originally spawns.

d3d_light_define_point(vLightID,x,y,z-64,128,c_white);

couldnt you do for the x and y define the point of a different object like i mean create a different object and then tell the object to direction=point_direction()
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users