Skip to content

Rotate Object by Tag?

I've been using SetFacing() to rotate objects using the OnUsed on the usable Object. But is there way to rotate an object from a distance without actually clicking it? Perhaps by Tag?





Comments

  • ForSeriousForSerious Member Posts: 446
    // Sets a visual transform on the given object.
    // - oObject can be any valid Creature, Placeable, Item or Door.
    // - nTransform is one of OBJECT_VISUAL_TRANSFORM_*
    // - fValue depends on the transformation to apply.
    // Returns the old/previous value.
    float SetObjectVisualTransform(object oObject, int nTransform, float fValue, int nLerpType = OBJECT_VISUAL_TRANSFORM_LERP_NONE, float fLerpDuration = 0.0, int bPauseWithGame = TRUE)
    
    Maybe.
  • ProlericProleric Member Posts: 1,268
    edited October 2021
    SetFacing() will also work from any script - for example, a trigger or lever at a distance. AssignCommand() can be used to tell a different object to rotate.

    There is a subtle difference - SetObjectVisualTransform only changes the visual appearance, whereas SetFacing rotates the entire model, including Use nodes etc.
  • BuddywarriorBuddywarrior Member Posts: 62
    Proleric wrote: »
    SetFacing() will also work from any script - for example, a trigger or lever at a distance. AssignCommand() can be used to tell a different object to rotate.

    I cant figure out the SetFacing() Proleric, do you know how? I'm reading it as "void SetFacing(float fDirection)" so it can't be assigned to another object and only OBJECT_SELF. I would rathe be wrong.


    For example if I want to rotate oTarget.
    
    object oPC = GetItemActivator();
    object oTarget = GetItemActivatedTarget();
    
    float x = GetFacing(oTarget);
    
    x+=10.0;
    
    //So close to GetFacing, but it only takes the direction not the object so this won't work.
    SetFacing(oTarget, x);
    
    
    ///Now to rotate oTarget
    //C# has me wanting to do.. obviously this doesn't work.
    oTarget.SetFacing(x);
    
    //of course this isn't right either.
    oTarget = SetFacing(x);
    
    
    
  • ProlericProleric Member Posts: 1,268
    Try
    AssignCommand(oTarget, SetFacing(x));
    

    This makes oTarget the object of the SetFacing() function.
    ForSeriousBuddywarrior
  • BuddywarriorBuddywarrior Member Posts: 62
    And knowing is half the battle. You rock, thank you!
Sign In or Register to comment.