Jump to content

Get the rotation and position of the Reference to which the script is attached to


Recommended Posts

Good evening everybody!

 

Ok, so I know how to get the rotation and positon of an object reference.

But how can I get those values for the object to which the script is attached to?

 

I tried to do something like this:

float Xpos = self.GetPositionX();

but got an error:

no viable alternative at input 'self'

So, how can this be done?

Link to comment
Share on other sites

Try this:

 

float xPos = (Self as ObjectReference).GetPositionX();

Nope, didn't work.

Now I get the following error:

GI_Rotate_on_Queststage.psc(11,13): no viable alternative at input '('
GI_Rotate_on_Queststage.psc(11,19): required (...)+ loop did not match anything at input 'as'
GI_Rotate_on_Queststage.psc(11,6): Unknown user flag self
Link to comment
Share on other sites

What is it that you want to take the position of, exactly?

 

Generally speaking, if it's not an object reference, or a subclass of objref, then it doesn't exist in-world and has no meaningful co-ordinates.

It is one of those "rotation markers".

So it is an object reference.

 

But I can't use the ref id as a property, because apparently you can't pass the object to which the scirpt is attached to to the script as a property.

Link to comment
Share on other sites

Event if the script is attached to an object reference, you can still use that object reference as a property:

Scriptname TEMP extends ObjectReference Const

ObjectReference Property TEMP_ObjRef Auto Const    ;you can fill this property with "itself"

Event OnLoad()
	JustAFunction()
EndEvent

Function JustAFunction()
	float xPos = TEMP_ObjRef.GetPositionX()
EndFunction
Edited by LarannKiar
Link to comment
Share on other sites

But I can't use the ref id as a property, because apparently you can't pass the object to which the scirpt is attached to to the script as a property.

 

 

So

 

  • you placed a rotation helper in a cell
  • stuck a script on a the rotation helper
  • and then tried to give the rotation marker script a property pointing at the rotation marker

Is that about right?

 

Because you wouldn't need a property in that case - just use "self"

Link to comment
Share on other sites

 

But I can't use the ref id as a property, because apparently you can't pass the object to which the scirpt is attached to to the script as a property.

 

 

So

 

  • you placed a rotation helper in a cell
  • stuck a script on a the rotation helper
  • and then tried to give the rotation marker script a property pointing at the rotation marker

Is that about right?

 

Because you wouldn't need a property in that case - just use "self"

 

 

Yes, that's what I tried to do!

 

If I use "self" for anything else other then self.TranslateTo(....) I get errors.

Link to comment
Share on other sites

I admit, I never tried attaching a script to the helper. I had a ring and a pivot and I put the script in the pivot. The rotation of the helper is absolute, so you don't need to query it's rotation, just have the script remember where you sent it last.

 

Look at the one in Big John Salvage for an example

Link to comment
Share on other sites

  • Recently Browsing   0 members

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