Saturday, February 14, 2026
spot_img

Clampf does not work in iOS native? (Simulator) – Cocos Creator


That is my first time porting my sport over to iOS. The sport works and just about all of the capabilities wordk. Nevertheless I’ve observed a bizarre downside the place my characters “eyes” place usually are not being clamped. This isn’t an issue when testing on internet or web-mobile.

Right here is the code and I highlighted the code that’s not getting referred to as it appears. However iOS simulator X code shouldn’t be throwing up any error messages with reference to this code. It simply looks like the code isn’t getting referred to as in any respect, prefer it’s commented out or one thing.


      // Set the world place of the eyes
      this.eyes.setWorldPosition(desiredNewWorldPosition.x, desiredNewWorldPosition.y, desiredNewWorldPosition.z);
      //Restrict the eyes place
      this.eyes.place.clampf(new Vec3(-2.0, -2.0, -2.0), new Vec3(2.0, 2.0, 2.0)); //

I confirmed its the this.eyes.place.clampf(new Vec3(-2.0, -2.0, -2.0), new Vec3(2.0, 2.0, 2.0)); by commenting it out on my native working in a browser and its not a difficulty, i’m utilizing CocosCreator (3.8.3)

The simulator is working iOS model 17.5, iPhone 15 being simulated.
Xcode is model 15.4.

Can’t see any large errors, tried trying to find Clampf and Math however no errors/warnings about it.

I additionally observed that there’s the identical difficulty within the inbuilt simulator.

Edit:

I wrote my very own clamp code and the difficulty is now not there. I’m virtually 100% positive this is a matter contained in the cocoscreators place.clampf operate when it will get turned to Native code. Surprisingly no errors, undecided if it’s getting skipped outright.

Does this bug exists in IPA?

@jamessimo does this.eyes is a node? If that’s the case, then Node.place is a readonly property. You can’t modify it in native. As on native platforms, it returns a temple JS object, so modify the temple object can’t take impact on native platforms.

You need to use Node.place = xxx; to switch Node.place.

Thanks for the reason. I would love some warnings possibly when constructing iOS that some capabilities might not work on account of making an attempt to vary Learn solely objects.

As typescript lacks of the mechanism to keep away from the operation. And warning message for readonly capabilities usually are not a good suggestion. Certainly, there’s a documentation about it: Improvement Notes | Cocos Creator.



1 Like

Hey, that’s a tough one. You’ve executed job narrowing down the issue. From what you’re describing, it actually does seem to be the constructed‑in clampf is simply not working when compiled to iOS. Since your personal clamp methodology works nice, that’s a stable workaround for now. It could be price submitting a bug report back to the Cocos crew with all the small print you’ve discovered. No less than you will have an answer in place till that is mounted in a future model.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles