Select to view content in your preferred language

Update ArcGis Location of GameObject / Sprite

561
2
Jump to solution
08-19-2022 10:21 AM
LuisKaiser
Emerging Contributor

Hello everyone,

I have a SniperRifle as GameObject with a sprite as symbol which has a ArcGisLocation.

See inspector:

 

InspectorSniperRifle.JPG

I want to update the Arcgis Location to the position of my mouse when I press Q.

I wrote this source Code but it doesn't work:

SourceCode.JPG

So when I press Q the gameObject (sniper Rifle) is away.

I would like to get the Arcgis-Location of my mouse when I press Q and set it to my gameObject.

I am very happy if you help me.

0 Kudos
1 Solution

Accepted Solutions
Matt_Nelson
Esri Alum

 

var worldPosition = math.inverse(arcGISMapComponent.WorldMatrix).HomogeneousTransformPoint(posMouse.ToDouble3());
var geoPosition = arcGISMapComponent.View.WorldToGeographic(worldPosition);

sniperRifle.GetComponent<ArcGISLocationComponent>().Position = geoPosition;

 

View solution in original post

0 Kudos
2 Replies
Matt_Nelson
Esri Alum

 

var worldPosition = math.inverse(arcGISMapComponent.WorldMatrix).HomogeneousTransformPoint(posMouse.ToDouble3());
var geoPosition = arcGISMapComponent.View.WorldToGeographic(worldPosition);

sniperRifle.GetComponent<ArcGISLocationComponent>().Position = geoPosition;

 

0 Kudos
LuisKaiser
Emerging Contributor

Great,

thank you very much 👍

0 Kudos