Is there a way to setup auto load of orbit camera on mobile, and auto load first person on desktop?
Also, my sound auto plays on desktop, but does not on mobile. Is this a known issue? Or do I need to script auto play for mobile?
Is there a way to setup auto load of orbit camera on mobile, and auto load first person on desktop?
Also, my sound auto plays on desktop, but does not on mobile. Is this a known issue? Or do I need to script auto play for mobile?
Hi @roustan and welcome,
You can have the two controllers (orbit and first person) on two separate entities, initially disabled.
Then use the pc.platform object and its mobile property to check which entity to enable on launch:
// pseudo code
if(pc.platform.mobile){
// enable orbit entity
}else{
// enable first person entity
}
thank you. what would be the command I’d write to enable orbit entity? I’m a total noob at this stuff.
There are several ways, an easy one is to use the Orbit entity name. Let’s say its name is My Orbit Camera
, then do this:
if(pc.platform.mobile){
this.app.root.findByName('My Orbit Camera').enabled = true;
}else{
// enable first person entity
}
Okay, I made these:
and then added this script in PC.Platform:
How does it know which object is “first person view”?
I need to be explained to like I’m five honestly
Was able to solve by calling up a coder friend to help me:
var Isdesktop = pc.createScript('isdesktop');
// initialize code called once per entity
Isdesktop.prototype.initialize = function() {
console.log(pc.platform);
if(pc.platform.desktop){
this.app.root.findByName('First Person').enabled = true;
console.log("i am on desktop");
}
else{
this.app.root.findByName('First Person').enabled = false;
this.app.root.findByName('Orbit Camera').enabled=true;
console.log("i am on mobile");
console.log(this.app.root.findByName('Orbit Camera'));
}
};
Nice and thanks for sharing the final solution @roustan!
We should propose that more often in the forum as a solution