Grimtongue Posted July 15, 2014 Share Posted July 15, 2014 I'm working on a mod that places 10 prefabs in-a-row with respect to the camera orientation. I don't want to simply use one prefab for North-South, a different one for East-West, and two more for the diagonals. Doing it that way should work, but it would be cumbersome for the player to have four options in the structures tab for every type of wall (and some other stuff). My strategy right now is using a custom prefab of a "ghost wall" which is basically a plain image of 10 stone wall silhouettes to show the player where the walls will be placed. When the player puts the "ghost wall" prefab on the ground, the script removes it and sends the coordinates through an iteration to place 10 vanilla wall segments in a row at that location. I thought this would be simple to implement, but I'm having major trouble with orienting the prefab based on the camera angle. I've been looking through the game files, but I can't figure out what functions are going to give me the information needed for the script. It seems to me that every prefab is simply placed at a location without a specific orientation! I'm getting frustrated at this point, so if anyone could point me in the right direction I'd really appreciate it. Link to comment Share on other sites More sharing options...
Grimtongue Posted July 15, 2014 Author Share Posted July 15, 2014 [ignore second post, I was confused by forum layout] Link to comment Share on other sites More sharing options...
DevilXD Posted July 16, 2014 Share Posted July 16, 2014 Srlsly? You set that picture on your account and you don't know how to do stuff according to your camera angle? Hah, just kidding But, that's right - Pig King throws gold at your camera angle, so just look into 'prefabs/pigking.lua' for some code Hope I helped EDIT: The stuff that should interest you (from pigking.lua):local down = TheCamera:GetDownVec()local angle = math.atan2(down.z, down.x) + (math.random()*60-30)*DEGREES Link to comment Share on other sites More sharing options...
Grimtongue Posted July 16, 2014 Author Share Posted July 16, 2014 *all of the face-palms* I can't believe I missed that when I have the pig king as my profile picture... Thanks for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.