Rotate Towards

kotor

Member
I have a NPC character (UCC) and I am using movement task Rotate Towards. I have created a GameObject as marker and use Behavior Designer to rotate towards that marker. It is not working all I am seeing is, it lit up (Running). Any idea what I am doing wrong ?

Thanks
 
It seems like I can't even rotate the NPC character manually while it is running. Is there any settings on the NPC character that preventing it from rotating ?
 
The character controller sets the rotation every frame so that's why you are unable to rotate it. The correct solution is to use an ability to rotate the character instead of using a built-in Behavior Designer task.
 
I am trying to move NPC to a certain location and face it in certain direction. Will Move Towards ability work in this scenerio ?
 
Yes, it will. I haven't tried calling that ability from Behavior Designer but generally another ability starts the Move Towards ability instead of itself. In version 2.3 there is a Point and Click movement type which uses the Move Towards ability so you can likely do something similar as that where you call SetLocation on the ability.
 
Attached is an ability "Rotate Towards" that I have created. Still it is not rotating. I know I am doing something wrong. I am still new t it.

Can you identify the issue. It will be really helpful to me in my learning process.
 

Attachments

  • RotateTowards.cs
    2.6 KB · Views: 9
You cannot set the transform rotation directly as it will be overridden. You should instead set the rotation using the DeltaRotation property within the ability. Take a look at Aim.UpdateRotation for an example.
 
@Justin I tried to follow code what's in the Aim.UpdateRotation. Still I am not able to make it work. Maybe, I am not able to understand the code completely. I am trying to Rotate Towards a marker which is input to the script. I am attaching the script that I tried to come up. Let me know if you have any suggestion.
 

Attachments

  • RotateTowards.cs
    3.1 KB · Views: 25
You are setting the DeltaRotation so that looks good. Is the correct rotation being applied? Is the ability active? Also another ability may be overriding that rotation so I would test it without any other abilities enabled.
 
Is the correct rotation being applied?
I don't know the answer. I am not passing any rotation. The only thing that is being input is the Marker(GameObject). The agent should rotate towards that marker.

Is the ability active?
Yes I can see it its is getting Active.

Do you thing that part of the code looks OK ?

// Determine the direction that the character should be facing.
var lookDirection = m_LookSource.LookDirection(markerTransform.position, true,
m_CharacterLayerManager.IgnoreInvisibleCharacterLayers, false, false);
 
Yes, that code is ok. The DeltaRotation will rotate the character by the specified number of degrees. You can debug this by ensuring the DeltaRotation value is the correct delta for where you want to look.
 
Top