Jump to content

Recommended Posts

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.

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 :grin:

 

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
Edited by DevilXD

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...