Place Object at Cursor...

Post » Sat Jun 01, 2013 1:53 pm

I have been using this trig function to place objects ~ 90 units in front of the player, at a height of roughly 2/3 the player's height, and it works well for most situations:

PlacedObject.MoveTo(Game.GetPlayer(), 90.0 * Math.Sin(Game.GetPlayer().GetAngleZ()), 90.0 * Math.Cos(Game.GetPlayer().GetAngleZ()), 0.66 * Game.GetPlayer().GetHeight())

However, lately I have seen the need to not just place the object a fixed number of units in front of the player, but rather a fixed number of units in front of the angle the player is currently looking.

Try as I may, I can't seem to find a function that returns the player's viewing angle on the vertical axis.

User avatar
Rebekah Rebekah Nicole
 
Posts: 3477
Joined: Fri Oct 13, 2006 8:47 pm

Post » Sat Jun 01, 2013 3:40 am

http://www.creationkit.com/GetHeadingAngle_-_ObjectReference

If you look at the examples box on that page, they have written out pretty much what you need

EDIT: placing an object at the cursor can be accomplished as follows:

1. Make a new Explosion by duplicating one of the vanilla ones that use the invisible explosion object. Inside, select your object from the drop down list next to "placed object". Also tick the "Always Uses World Orientation" box

2. Make a new projectile, again by duplicating one of the vanilla ones that use the invisible model. Add your new explosion to it.

3. Make a new Magic Effect
Archetype: Script (?)
Casting Type: Fire and Forget
Delivery: Aimed
Then select your projectile under "Visual Effects"

4. Now make a new spell.
Type: Lesser Power (or Spell)
Casting Type: Fire and Forget
Delivery: Aimed
Add your Effect to the list on the right

5. Lastly you can do your angle adjustments from a script attached to the object's Base Object, inside an OnInit() event

- Hypno
User avatar
Ryan Lutz
 
Posts: 3465
Joined: Sun Sep 09, 2007 12:39 pm

Post » Sat Jun 01, 2013 6:48 am

You'll find...
Actor Property PlayerREF AutoPlacedObject.MoveTo(PlayerREF, 90.0 * Math.Sin(PlayerREF.GetAngleZ()), 90.0 * Math.Cos(PlayerREF.GetAngleZ()), 0.66 * PlayerREF.GetHeight())
...will resolve itself noticeably faster, placing the item with a bit more precision.
User avatar
..xX Vin Xx..
 
Posts: 3531
Joined: Sun Jun 18, 2006 6:33 pm


Return to V - Skyrim