Jump to content

GetHeadingAngle - Making an object face the player


Demeggy

Recommended Posts

Hi all,

 

well I'm trying something a little different here. I'm aiming to get a series of static objects to 'face' the player. Now I'm not entirely such the logical way to go about this.

 

Any suggestions? Have mulled over setAngle and getAngle on both player and object, but not having much luck.

 

The code I'm using falls into a doOnce statement;

 

        set angle to myObject.GetAngle Z + myObject.GetHeadingAngle player
       myObject.SetAngle Z angle

 

Thanks.

 

NB. Do they have to be movable static objects to be able to do this?

 

Kris

Link to comment
Share on other sites

Setangle/getangle, are the direction the object is facing in its current location.

 

So if you're looking due east, and your angle was thus like 90, then by setting its angle to the same, you're also rotating the object to face east. You're not MOVING the object, only spinning it to face the same way you are.

 

Doesn't have to be movable static, you can move anything pretty much.

 

I'm not sure if moveto has a way to assign translation based on player heading... placeatme does; it has an optional flag for position relative to the player (like 1 is in front of). Placeatme needs to be used with caution since it could cause savegame bloat.

 

http://geck.bethsoft.com/index.php/PlaceAtMe

 

http://geck.bethsoft.com/index.php/MoveTo

Link to comment
Share on other sites

GetHeadingAngle works great for actors to make them face a reference.

 

Now I'm wondering if you are doing the opposite, after setting the computed angle on the object, you may have to rotate (SetAngle Z) the object 90, 180, or 270 to make it actually 'face' the actor. Since many objects face in different directions when their Angle 'Z' is zero, compared to an actor.

Link to comment
Share on other sites

I get what youre both saying, but the code I've posted doesn't even move myObject at all. It's meant to be facing the player, and should work by that code, but I can't fathom why it won't.
Link to comment
Share on other sites

Just trying SetAngle Z on a static object at the console returns an error: cant move.

It does work on a car, though. So you will probably need to use moveable statics.

Link to comment
Share on other sites

Mhm, I'm trying it on an activator now as neither works, and it still isn't doing it. Basically, the moment the player hits a trigger, it's supposed to run that code in a doOnce and have the object facing the player...
Link to comment
Share on other sites

Hate to *bump*, but... *bump*. Okay, so i've tried everything. When the player enters the trigger, SETTING the angle manually (i.e. by 45, 180 etc) works, but the given code doesn't. Not sure what I'm doing wrong here.

 

To clarify.

 

When player is the trigger, the object must be facing the player's location.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...