# Shared AR object position issue

**URL:** https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047
**Category:** I'm Stuck
**Created:** [November 28, 2022, 11:41am UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047 "2022-11-28T11:41:58Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Naveen](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@Naveen](https://community.nianticspatial.com/u/Naveen)
#### Post date: [November 28, 2022, 11:41am UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/1 "2022-11-28T11:41:58Z")

</div>

_Include the following details (edit as applicable):_

- **Issue category** : Multiplayer
- **Device type & OS version** : Android
- **Host machine & OS version** : Windows
- **Issue Environment** : On Device
- **Xcode version** :
- **ARDK version** :2.3.0
- **Unity version** :2021.3

Description of the issue:  
I am a beginner to shared AR, so I am building a sample application to throw a ball to each other, but throwing a ball from a device causes others in the session to witness the ball going away from the camera rather than coming to the camera.

---

<div class="post-metadata">

### Author: ![rob\_link](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/rob_link/32/1176_2.png) [@rob\_link](https://community.nianticspatial.com/u/rob_link)
#### Post date: [November 28, 2022, 5:39pm UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/2 "2022-11-28T17:39:56Z")

</div>

Hello @Naveen

Would you mind sharing a bit more information about your scene and/or scripts? If you could attach any recordings and/or code snippets related to the ball-throwing logic, that may prove useful for getting to the bottom of things.

Also, do you happen to be using an `ARMeshManager` anywhere in your scene’s hierarchy?

---

<div class="post-metadata">

### Author: ![Naveen](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@Naveen](https://community.nianticspatial.com/u/Naveen)
#### Post date: [November 29, 2022, 4:30am UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/3 "2022-11-29T04:30:50Z")

</div>

hi @rob_link  
yes I am using ARMeshManager in my scene.  
I am attaching screenshots of my scripts and hierarchy window.

 ![Multiplayer1](https://us1.discourse-cdn.com/niantic/original/2X/9/9e4a619b70a2fab482f59507e24d19940e427611.png)

 ![Multiplayer2](https://us1.discourse-cdn.com/niantic/original/2X/2/2471d94a0569d7d1e61cb4d3076cb19276e5812d.png)

 ![Multiplayer3](https://us1.discourse-cdn.com/niantic/original/2X/4/41bde1885482fad8ccc53d6f1e49de3d7b74e107.png)

---

<div class="post-metadata">

### Author: ![rob\_link](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/rob_link/32/1176_2.png) [@rob\_link](https://community.nianticspatial.com/u/rob_link)
#### Post date: [November 29, 2022, 6:39pm UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/4 "2022-11-29T18:39:00Z")

</div>

Hmmm… you may want to try passing a desired rotation vector over the network in addition to passing the desired position. You could then pass that rotation into the `PlaceObject()` method where it could be used during the `rigidbody.AddForce()` call instead of `camera.transform.forward`.

I suspect that `camera.transform.forward` may always be resolving to the host camera’s `transform.forward` vector, which would explain why a client device always sees the ball being thrown behind them when standing across from a host device.

---

<div class="post-metadata">

### Author: ![Naveen](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@Naveen](https://community.nianticspatial.com/u/Naveen)
#### Post date: [November 30, 2022, 9:13am UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/5 "2022-11-30T09:13:01Z")

</div>

hi @rob_link thanks for your reply. I tried to implement your advice, but the problem persists.

---

<div class="post-metadata">

### Author: ![Naveen](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@Naveen](https://community.nianticspatial.com/u/Naveen)
#### Post date: [December 5, 2022, 4:05am UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/6 "2022-12-05T04:05:38Z")

</div>

Hi @rob_link any suggestions?

---

<div class="post-metadata">

### Author: ![rob\_link](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/rob_link/32/1176_2.png) [@rob\_link](https://community.nianticspatial.com/u/rob_link)
#### Post date: [December 7, 2022, 11:19pm UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/7 "2022-12-07T23:19:51Z")

</div>

Hello @Naveen,

We were unable to reproduce the exact issue that you reported with the spheres being thrown in reverse. However, we took the following steps to produce a scene in which different users in a networked session can successfully throw spheres that originate from their device’s position and rotation. You may want to follow these steps with a fresh project to see if this is the result you’re looking for. If so, you can compare the resulting project to your existing project in order to pinpoint the issue.

Starting with the **ARNetworking** scene that ships with the **ARDK Examples** package (located on the Downloads page [here](https://lightship.dev/account/downloads?tab=overview)), we opened the `ARNetworkingExampleManager.cs` script in order to make some changes.

First, we added an `Update()` function that checks for tap input from the user, and then calls an `OnScreenTap()` function that passes in the touch information.

 ![MhAypISgD6dvejtwnh93VpxnDb11OlMzxIrCenif7By-Y3fZbC1wrVViEPbERymtPm_EaOPeQmMVNpVeuFVJr-VCm399T85-w5GrvHcxmTxKree__vZqpQ-hmozy23BvSSK5OEOd5awmCRcFEXUVySaN25cAK8_8L36CfaJgkx-FsjefZfKR672-ntpp8A](https://us1.discourse-cdn.com/niantic/original/2X/7/7d432eac40effb222fd24bbcbfbe7e66ab3c12df.png)

Next, we added the `OnScreenTap()` function, which captures the current position and rotation of the local camera, serializes the information, and sends it across the network with a tag of `0`.

 ![VW86xTEy_K1HZI-Jf66qmjU-NxsVPhNZw5Wt_uqhqyypQmScfh-HjGYOKX2MtzHoBgfgxsY7SxZuA9WLJyqSgeaTxt9aOeFyRJwQmxv-3xoD6EYUlulV0DB9M-gEJ6-bwOn0ygz9fPsKah7MVapiy6LAS8BdeaAXKWewfhMvTVfuV6xpLHraPcnGL-u7hA](https://us1.discourse-cdn.com/niantic/original/2X/6/685505f305fb189c987c18c20f9dab7d25f45af9.png)

Then, in the `OnDidReceiveDataFromPeer()` function, we look for a message with the tag of `0`, and respond by deserializing the position and rotation that was sent and forward those values to a `ThrowBall()` function.

 ![wXT9_Sd9fR9sjDgsYeScZ7jqpY7I7TD7rIBD7ivuOqeVGEBzcl2xc1ViG_34c8cGrrzO1-slw4fUaGVUhXlVcwnJr1ZIBIdqS3HwkBidfpDRBaOKeC1wgyjkqmny-ohhIcg4a6dqiAxpliIya437y9kJ-zv0msXld6x2XtpFrlq2IRSXu5_aAQiJ7EubEg](https://us1.discourse-cdn.com/niantic/original/2X/5/5a172345d407dcbbe0ea6f97fce247541a5accae.png)

Next, we added a `ThrowBall()` function and `public GameObject ballPrefab;`  
field. This function instantiates a `ballPrefab` at the given position and rotation and adds a force along its forward vector.

 ![ebO38Qn_S5q5Psxgcsr2H8zTdUdTbHtphBu6aI_JiZTdwWBgAKt6rNBpiGZSb4K5Jauf9kJIYDhvVNY-zevWnnIZjs63Lej3DhQoIeTp-SKF2nVm--6BF5sVUGGln8WJ2Jpvnrk0qt3ilUlyIH9h9hOtOnRi2PPVax7e3oBTseYjqDVHt_N3nTkzN_oWGw](https://us1.discourse-cdn.com/niantic/original/2X/c/c79296d903ec782516e20a3187e7089f0d19b000.png)

Finally, we built a `Ball` prefab that has `Rigidbody` and `SphereCollider` components, while ensuring the prefab’s position and rotation values are all 0…

 ![p02UOYym6ipnMEQz6Xr8CJXLRA6z8wc94E-orleagyL52ODXqY_OT8vL_dU4A2W0khNrsvDRZsD6_YEuulmgnRfzuBp-rTrhx1AM14LpuVWYMLWyTFH3g3sU11A3Ppc7GaAvX9NWXgjBOlkEdpZGx72Oid-Gq3mG04SRaQbibPdACykNniwsSvOfsGLFow](https://us1.discourse-cdn.com/niantic/original/2X/f/f6a1091c0db017a43df0d628394affe2639fe557.png)

…and then assigned this prefab to the `ARNetworkingExampleManager` component on the `ExampleManager`.  
 ![BlPoTEXwmzAoF56GZSjNAMfbvX38TCjDisei8VU6dsqWt8lAlChKIpatpSrj16ZfW4eJm7NW3-87xlXqSDKUYIugVoJuMP4yPWDgWDImW_EVdPCa6JoDCTn96BWz5y8mgqdcIX1gfAHry6iOH_uYx8rR0HemF7YJJFPBfITlhYOrzn52SbfBHxjygjTinQ](https://us1.discourse-cdn.com/niantic/original/2X/e/e2a39cf8ae65b9667d71b46fedfa0a12bd311686.png)

The resulting scene demonstrates an environment in which players can throw balls forward from their device position and rotation.  
 ![BallExample](https://us1.discourse-cdn.com/niantic/original/2X/e/eb98231bae1573cb1860c52b43038eafada7f45d.gif)

Let us know if this example grants some insight into the methodology used, and if you have any other questions about how to achieve the desired effect.

P.S. - If you’re observing unreliable physics results when testing in one of the Virtual Studio mock environments, you may want to check the mock environment prefab for any colliders that may be affecting your rigidbodies in the scene. For example, the `ParkPond` prefab erroneously contains an active `Box Collider` component that will interfere with spheres thrown within the mock environment unless deactivated.

 ![IXhCo7MxzlAUNAl-T5qLZQcDGPgr3o8cDMuKnwLSzEt51RBVNPPCD5rIEckLWCEsF6FGymog_zMn9SRpXsGN3-5IOFMndvwm9pn91hdxbhyQqzIRl_i3OIYvUx3sq-hAAhRZrlN5rc7uQ5H5nHSrLaCrFJTLAkGOl0rxAoyquMAQDldLImd5zEq0Ba7jww](https://us1.discourse-cdn.com/niantic/original/2X/0/03ce8b0334937d9e4fb5c5e565ad81a30745a149.jpeg)

We’ve escalated this particular issue internally and it will be addressed in a future ARDK release. Happy building!

---

<div class="post-metadata">

### Author: ![Naveen](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@Naveen](https://community.nianticspatial.com/u/Naveen)
#### Post date: [December 13, 2022, 8:33am UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/8 "2022-12-13T08:33:07Z")

</div>

hi @rob_link, that’s great. It worked. Thank you so much

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/system/32/13_2.png) [@system](https://community.nianticspatial.com/u/system)
#### Post date: [December 13, 2022, 10:33am UTC](https://community.nianticspatial.com/t/shared-ar-object-position-issue/3047/9 "2022-12-13T10:33:31Z")

</div>

This topic was automatically closed 2 hours after the last reply. New replies are no longer allowed.
