ID:1435166
 
(See the best response by Ss4toby.)
Whats the easiest way to make a projectile object spawn in a certain position based on the mob it's owned by, while using pixel movement? For example having an "arrow" object spawn 4 pixels east, and in the center of the source before it starts moving right? My recent attempts have just had the object spawning in the center of the closest tile, then moving east.
Best response
Ummm...

mob/verb/CreateObject()
var/obj/EG/o=new(loc)
o.step_x=step_x
o.step_y=step_y
step(O,dir)//Make it move once in your direction.


As for the best way, I honestly don't know. If you're using angles, you could simply have that calculated into the step_x and step_y setting process.

mob/verb/CreateObject(ang as num)
var/xAdd=cos(ang)
var/yAdd=sin(ang)
var/obj/EG/o=new(loc)
o.step_x=step_x+(xAdd*o.step_size)
o.step_y=step_y+(yAdd*o.step_size)
//I used step_size as an example, but honestly a different value might be more desirable.


You could even use the built in directions if desired. Would just need a means of telling what direction was what angle.

mob/verb/CreateObject()
var/list/dirs=list(1=90,4=0,8=180,2=270,5=45,9=135,10=225,6=315)
var/ang=dirs[dir]
var/xAdd=cos(ang)
var/yAdd=sin(ang)
var/obj/EG/o=new(loc)
o.step_x=step_x+(xAdd*o.step_size)
o.step_y=step_y+(yAdd*o.step_size)