Turn Based Random ActorNumber ID - random

Good day!
I have a chess game with PUN. My question is that whenever the one who creates the room first usually is the first to move (white player). And the one to join is the black player.
I was hoping that creating a room and joining would randomize who is white and black and not by the one who creates and joins.
`
myClientID = PhotonNetwork.LocalPlayer.ActorNumber;
myPlayer = PhotonNetwork.Instantiate("Player", Vector3.zero, Quaternion.identity);
myPlayer.GetComponent<Player>().myId = myClientID;
`
that is the code above being used. It might not be the best practice. please help on how to have a randomize player id. Or if there is another best practice approach please let me know. Thank you in advance.

Related

How to project (or paste)panorama to model?

Before question,I seached many places, I find some similar idea but without my solution.And my question can be also described as how to recalculate the model's uv to fix the panorama designed for six faces skybox.
Recently,I came upon a unique way to get fluent 3D roaming experience on matterport's Official network https://matterport.com/gallery/
I just want to know how did they do that?Their product is very fluent when swich the panorama picture.
After I roaming many times,I found the secret. I realized that the panorama carrier they use is not box or sphere,but is the object they show first!The evidence is that when switch the point,the object such as chair and table would have their own shadow(one chair have two image one stand up and the other one lie on the floor
With the object in panorama paste on their own correspond object and with depth information the roaming switch become more fluent (As for why they do not use the object directly ,I think because of the limited hardware,Many irregularity faces which get from scanning equipment cannot be use directly
And I want to use this idea in my project ,I have a group of six panorama which can paste on a boxGeometry perfectly,and I just want to paste them on model.but I stuck in project 360 degree.Yes I just find how to project one direction but I cannot project the remaining five.
var _p=BufferGeometry.attributes;
for (var i = 0; i < _p.position.count; i++){
var uvtempbeforeconvert= ( new THREE.Vector3(_p.position.array[3*i],_p.position.array[3*i+1],_p.position.array[3*i+2]) ).clone().applyMatrix4(houseObject.matrixWorld).project(camera1)
//use the worldvertices to get its screen coordinate
if(uvtempbeforeconvert.x<1&&uvtempbeforeconvert.x>-1 && uvtempbeforeconvert.y<1 &&uvtempbeforeconvert.y>-1) {
VerticesArray1.push(_p.position.array[3*i],_p.position.array[3*i+1],_p.position.array[3*i+2]);uvArray1.push(uvtempbeforeconvert.x*0.5+0.5,uvtempbeforeconvert.y*0.5+0.5);
Yes,I success in calculating one direction.BUT I cant deal with the triangle faces which occupy two more view frustum,like a face at the edge of the box.
How should I deal with this problem?Or I run in the FALSE direction at first?Which direction should i run in ?
After asking many people,I just find that I need to usd shadermaterial in threejs ,and use a function named cubetexture,samplercube.With that I can get the pixel color what I need!

3dsmax FFD transform control point manipulation by script

Hello everyone interested in maxscript,
I would like to make a batch of rock models deformed by FFD. To achieve efficiency, I need to write a script to manipulate the control points for random deformation.
I opened the listener and move the control point manually, but no message pop up to offer reference. So it seems hard for me to solve this problem on myself.
Could you kindly give me a concise example on how to do that? Thank you very much!!!
Best,
Yiyang
FFD control points are animated like editable mesh vertexes.
Hopefully this will work:
b = box()
addmodifier b (FFD_2x2x2())
animateAll b.modifiers[#FFD_2x2x2]
getPropNames b.modifiers[#FFD_2x2x2] #dynamicOnly --prints properties which you can animate
with animate on
(
at time 50
b.modifiers[#FFD_2x2x2].Control_Point_1 = [0,-2,0]
)
playanimation()

argon-aframe move with the users geolocation

I have this project:
my codepen
I want to be able to move forward when the user walks, so it feels like they are walking thru the floor plan in VR as they are in real life.
my goal is get the geolocation of the user and show them the room matching theirs location and have them walk around the room while viewing the AR on the phone they would see paintings on the walls.
my challenges are:
walk in real life and move in VR (right now I have it auto walking forward in the meantime)
var speed = 0.0;
var iMoving = false;
var velocityDelta;
AFRAME.registerComponent("automove-controls", {
init: function() {
this.speed = 0.1;
this.isMoving = true;
this.velocityDelta = new THREE.Vector3();
},
isVelocityActive: function() {
return this.isMoving;
},
getVelocityDelta: function() {
this.velocityDelta.z = this.isMoving ? -this.speed : 0;
return this.velocityDelta.clone();
}
});
capture the user geo location so the moment they open the site they are placed relative to their location on the floor plan
this is my first attempt so any feed back would be appreciated.
As far as i know argon.js is more about geoposition than spatial/marker based augmented reality.
moreover It's quite worrying, that their repo for aframe was not touched for a while.
Argon seems like a library for creating scenes in certain points around the user, even their examples base on positioning stuff around, reason being the GPS/phone accelerometers are way too bad to provide useful data for providing spatial positioning. Thats why VIVE needs two towers, and other devices at least a camera/IR device, to get information about the HMD device.
Positioning the person inside a point depending where are they in a room is quite a difficult task, You would need to get a point of reference and position the user accordingly. It seems impossible, since the user can be anywhere in the world.
I would try to do this using jerome-etienne's marker based AR.js. The markers would be the points of reference You need, and although image processing seems like a difficult task, AR.js is surprisingly stable with multiple markers, which help in creating complex scenes.
The markers seems like a good idea, for they can help You with the positioning, moreover simple scenes have no problem with achieving 60+fps, making the experience quite comfortable.
I would start there, since AR.js seems to be updated frequently.

How to randomly shuffle images into picture boxes in Visual Basic Forms?

So I have a 6x4 arrangement of picture boxes drawn on my form. My idea is to create a matching game. I want to add images to the picture boxes randomly each time so that they're not in the same position each time someone plays the game. The images will be stored in a file somewhere on my computer. I'm kind of lost at how to approach this. So far I have:
Public Class Board
Dim cards(23) As Image
Dim random As New Random
Public Sub shuffle()
For i = 0 To cards.Length - 1
cards(i) = i
Next i
End Sub
End Class
This hasn't really gotten me anywhere. I'm kinda new to using VB for things like this so I'd appreciate any suggestions. Also, the pictures that will be matched aren't exactly the same so I want to add 24 images and not 12 images x 2. Eventually I'll have to figure out the conditions for matching but for now I just want to be able to fill the boxes. And I was wondering if it's worth using OOP or is this not complex enough for that. Thanks in advance.

Slowing down looping animation as3

This is the first time I've ever posted in a forum, so thanks in advance for anyone who takes the time to read/answer this question.
What I'm trying to create is basically a flipping coin animation, which starts off turning very fast and then slows down to stop with a (randomly generated) side facing upwards after about 8 seconds.
I've done the animation of a complete flip, which lasts about half a second, and made it in to a movieclip... now I'm stuck!
Any ideas how I might go about doing this in actionscript3?
The fastest way around this would be to use some very basic actionscript. First, create 2 animations (One heads, one tails). Now, you only need a single frame for this and don't need to place the movieclips on the stage. Use the following or similar code:
var whichSide:int = 0;
var coin1:coinAnimation1 = new coinAnimation1();
var coin2:coinAnimation2 = new coinAnimation2();
whichSide = math.Round(math.Random(1));
if(whichSide == 1)
{
addChild(coin1);
}
else
{
addChild(coin2);
}
Just don't forget to right click the movieclip and export for actionscript, giving the movieclips the class of: coinAnimation1 and coinAnimation2.
Hope this helps.
I've accomplished such animation on ´Keyframes´ using the Tweener class. You can easily tween on the keyframe parameter with specific transition...
Basic example:
Tweener.addTween(myMovieClip, {_frame:10, time:2.5});
More information about Tweener here

Resources