dagobaking Posted November 26, 2017 Share Posted November 26, 2017 (edited) Hello. I have an ObjectReference generated by using the function FindAllReferencesWithKeyword to a character in the game. However, I need to have a pointer to their Actor class. How do I get that from an ObjectReference? I tried GetBaseObject, GetActorBase and GetLeveledActorBase (maybe incorrectly) and couldn't get it to work. For reference, this is the function I'm working on: Function lookAt(ObjectReference target) Actor a = target as Actor Game.SetCameraTarget(a) EndFunction Thank you. ADDITIONAL INFO: I traced "a" from the above script and get "workshopnpcscript" which isn't what I expected. Is there a way to get the Actor reference I need for SetCameraTarget from that? Edited November 26, 2017 by dagobaking Link to comment Share on other sites More sharing options...
ScottyDoesKnow Posted November 26, 2017 Share Posted November 26, 2017 (edited) I don't know how to check what type a reference is, unless there's a keyword for actor (in which case you can check hasKeyword on each one). But it looks like you can cast and then just check if it's null/None. https://www.creationkit.com/index.php?title=Cast_Reference Edit: this is assuming you're actually getting references of different types. If it's a keyword that's only on actors then the cast should always just work. Edited November 26, 2017 by ScottyDoesKnow Link to comment Share on other sites More sharing options...
SKKmods Posted November 26, 2017 Share Posted November 26, 2017 (ObjectRef as Actor).GetActorBase() Link to comment Share on other sites More sharing options...
dagobaking Posted November 26, 2017 Author Share Posted November 26, 2017 Thank you both. I did some more testing by traveling out of the workshop area and running this function on other NPCs. That traced those references as "Actor". But, the result still wasn't as expected. So, it looks like casting the objectreference was working. It's just that the "SetCameraTarget" function didn't do what I thought it would. I expected it to aim the players first person camera toward the target. It looks like it changes the camera position only in third person view. And in a kind of un-useful way... Anyone know if there's a way to point the camera at another actor like I was trying to do? Link to comment Share on other sites More sharing options...
NikaCola Posted November 28, 2017 Share Posted November 28, 2017 Anyone know if there's a way to point the camera at another actor like I was trying to do?If I could figure this out, I would be a happy, happy camper. =( Seriously, I've been trying for months. I don't suppose there's any dialogue happening when that script fires? In that case it's a bit easier (though still not super reliable in my experience) to get the camera to look in certain directions. I did find this post though that might help...at the end he figures out something that you might be able to put into your script? https://forums.nexusmods.com/index.php?/topic/5546997-setcameratarget-does-not-work-as-expected/ The only other thing I can think of is digging through the base game quests and seeing if this happens at any point in the MQ? If you do find anything please let me know, as I'm also really struggling with this. Link to comment Share on other sites More sharing options...
Recommended Posts