public void UpdatePosition(Vector3 newPos, PositionConstraint constraint) { xyPosition.x += newPos.x; xzPosition.x += newPos.x; xyzPosition.x += newPos.x; if (constraint == PositionConstraint.XY) { xyzPosition.y += newPos.y; xyPosition.y += newPos.y; } else if (constraint == PositionConstraint.XZ) { xzPosition.z += newPos.z; xyzPosition.z += newPos.z; } else if (constraint == PositionConstraint.XYZ) { xyzPosition.y += newPos.y; xyzPosition.z += newPos.z; xyPosition.y += newPos.y; xzPosition.z += newPos.z; } }
// Start is called before the first frame update void Start() { //マスの番号ごとに座標を設定 Vec = new Vector3((float)PosX * 10.0f, 0.1f, (float)PosZ * 10.0f); //Vec = GameObject.Find("Floor").transform.position; //this.transform.position = Vec; //初期位置を元に番号セット Array_X_Num = PosX; Array_Y_Num = PosZ * 7; Old_Array_X_Num = 0; Old_Array_Y_Num = 0; this.UpdateAsObservable().Where(_ => this.isActive && this.MySts). Subscribe(_ => Controller()); this.UpdateAsObservable().Take(1).Subscribe(_ => FastFlame = true); //UpdateでY座標のみセット(1回のみ) this.UpdateAsObservable().Take(1). Subscribe(_ => this.transform.position = new Vector3(Vec.x, 0.1f, Vec.z)); // 追従用の初期化 this.gameObject.AddComponent <PositionConstraint>(); this.myPositionConstaint = GetComponent <PositionConstraint>(); }
// Start is called before the first frame update void Start() { this.gameObject.AddComponent <PositionConstraint>(); MyPositionConstraint = GetComponent <PositionConstraint>(); TotalPower = Power; }
public void Write(TProtocol oprot) { oprot.IncrementRecursionDepth(); try { TStruct struc = new TStruct("MWalkPoint"); oprot.WriteStructBegin(struc); TField field = new TField(); if (PositionConstraint == null) { throw new TProtocolException(TProtocolException.INVALID_DATA, "required field PositionConstraint not set"); } field.Name = "PositionConstraint"; field.Type = TType.Struct; field.ID = 1; oprot.WriteFieldBegin(field); PositionConstraint.Write(oprot); oprot.WriteFieldEnd(); field.Name = "Suitability"; field.Type = TType.Double; field.ID = 2; oprot.WriteFieldBegin(field); oprot.WriteDouble(Suitability); oprot.WriteFieldEnd(); oprot.WriteFieldStop(); oprot.WriteStructEnd(); } finally { oprot.DecrementRecursionDepth(); } }
void SwitchCamera(Transform t) { if (onLock && t) { if (t != player) { lockIcon.gameObject.SetActive(true); PositionConstraint pc = lockIcon.GetComponent <PositionConstraint>(); if (pc) { if (pc.sourceCount > 0) { pc.RemoveSource(0); } constraintSource.sourceTransform = t; constraintSource.weight = 1; pc.AddSource(constraintSource); //pc.translationOffset = Vector3.zero; //pc.translationAtRest = Vector3.zero; } lockVcam.GetComponent <CinemachineVirtualCamera>().LookAt = t; lockVcam.GetComponent <CinemachineVirtualCamera>().Priority = mainPriority + 1; return; } } lockIcon.gameObject.SetActive(false); lockVcam.GetComponent <CinemachineVirtualCamera>().Priority = mainPriority - 1; }
public void UpdatePosition(Vector3 newPos, PositionConstraint constraint) { xyPosition.x += newPos.x; xzPosition.x += newPos.x; xyzPosition.x += newPos.x; if (constraint == PositionConstraint.XY) { xyzPosition.y += newPos.y; xyPosition.y += newPos.y; } else if (constraint == PositionConstraint.XZ) { xzPosition.z += newPos.z; xyzPosition.z += newPos.z; } else if (constraint == PositionConstraint.XYZ) { xyzPosition.y += newPos.y; xyzPosition.z += newPos.z; xyPosition.y += newPos.y; xzPosition.z += newPos.z; } int id = wpGroup.waypoints.IndexOf(this); if (id > 0) { rotation = Quaternion.LookRotation(position - wpGroup.waypoints[id - 1].position); } }
public Vector3 GetPosition(PositionConstraint constraint = PositionConstraint.XYZ) { if (wpGroup != null) { constraint = wpGroup.XYZConstraint; } if (constraint == PositionConstraint.XY) { position = xyPosition; } else if (constraint == PositionConstraint.XZ) { position = xzPosition; } else { position = xyzPosition; } /* * if (wpGroup != null) * return wpGroup.transform.position + position; * else*/ return(position); }
private static void DuplicateRigTarget() { Smart3DOFTarget b = Selection.activeGameObject.GetComponent <Smart3DOFTarget>(); Transform cam = b.reference; PositionConstraint constraint = cam.GetComponent <PositionConstraint>(); BuildView(b.gameObject.name + " Duplicate", b.transform.position, b.transform.forward, cam, constraint, constraint.sourceCount, 0); }
private static void AddRigTarget() { Smart3DOFTarget b = Selection.activeGameObject.GetComponent <Smart3DOFTarget>(); Transform cam = b.reference; PositionConstraint constraint = cam.GetComponent <PositionConstraint>(); BuildView("New Target", Vector3.zero, Vector3.forward, cam, constraint, constraint.sourceCount, 0); }
private void Awake() { aiPathStatus = gameObject.GetComponent <Pathfinding.AIPath>(); positionConstraint = gameObject.GetComponent <PositionConstraint>(); rigidbody = gameObject.GetComponent <Rigidbody>(); monsterControl = GameObject.Find("GameManager").GetComponent <MonsterControl>(); HookObj = GameObject.Find("Hook").gameObject; }
private static void RemoveRigTarget() { Smart3DOFTarget b = Selection.activeGameObject.GetComponent <Smart3DOFTarget>(); Transform cam = b.reference; PositionConstraint constraint = cam.GetComponent <PositionConstraint>(); constraint.RemoveSource(b.index); DestroyImmediate(b.gameObject); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { cameraControl = animator.GetComponent <CameraControl>(); targetFocus = cameraControl.targetFocus; positionConstraint = animator.GetComponent <PositionConstraint>(); positionConstraint.constraintActive = false; gameObjectTransform = animator.gameObject.transform; targetPosition = targetFocus.position + offsetFocus; }
//Pos Constrait------------------------------------------------------------- //Clear Sourcers public static void ClearSources(this PositionConstraint posCons) { int length = posCons.sourceCount; for (int i = 0; i < length; i++) { posCons.RemoveSource(0); } }
//Add Sourcer public static void AddTransform(this PositionConstraint posCons, Transform source, float weight = 1) { ConstraintSource constraint = new ConstraintSource(); constraint.sourceTransform = source; constraint.weight = weight; posCons.AddSource(constraint); }
public override string ToString() { StringBuilder __sb = new StringBuilder("MWalkPoint("); __sb.Append(", PositionConstraint: "); __sb.Append(PositionConstraint == null ? "<null>" : PositionConstraint.ToString()); __sb.Append(", Suitability: "); __sb.Append(Suitability); __sb.Append(")"); return(__sb.ToString()); }
protected virtual void CreateFootPrints() { _footprints = Instantiate <GameObject>(Resources.Load <GameObject>("Footprints/Footprints")).GetOrCreateComponent <PositionConstraint>(); _footprints.transform.ResetTransformation(); ConstraintSource source = new ConstraintSource(); source.sourceTransform = transform; source.weight = 1.0f; _footprints.AddSource(source); _footprints.constraintActive = true; }
// Start is called before the first frame update void Start() { distanciaAlObjeto = Vector2.Distance(fnt_ObetenerPlanoAereo(transform.position), fnt_ObetenerPlanoAereo(pelota.position)); dot = Vector2.Dot(fnt_ObetenerPlanoAereo(transform.position).normalized, fnt_ObetenerPlanoAereo(pelota.position).normalized); rad = Mathf.Acos(dot) + (180f * Mathf.Deg2Rad); camera = Camera.main.transform; camera.LookAt(pelota); whiteballRigid = pelota.GetComponent <Rigidbody>(); constrainPos = GetComponent <PositionConstraint>(); constrainPos.constraintActive = true; }
protected override void Awake() { base.Awake(); transform.MoveToHell(); constraint = GetComponent <PositionConstraint>(); follower = GetComponent <UITargetFollower>(); if (follower) { follower.enabled = false; } }
// Use this for initialization void Start() { xStraint = GetComponent <PositionConstraint>(); if (xStraint) { xStraint.locked = true; xStraint.constraintActive = true; xStraint.translationAxis = Axis.X; xStraint.weight = 0f; } offset = transform.position - target.position; // Subtracts target (player's) position from camera's position to get the difference (offset). }
void Start() { if (!constraint) { constraint = GetComponent <PositionConstraint>(); } if (!player) { player = GameObject.Find("Player_parent").transform; } LookAtPlayer(); previousPlayerPosition = player.position; }
// Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player").transform; PositionConstraint posConstraint = GetComponent <PositionConstraint>(); posConstraint.ClearSources(); posConstraint.AddTransform(player); LookAtConstraint lookConstraint = Camera.main.GetComponent <LookAtConstraint>(); lookConstraint.ClearSources(); lookConstraint.AddTransform(player.Find("LookAtTarget")); }
private void Awake() { if (!reference && Camera.main) { reference = Camera.main.transform; } if (!positionConstraint) { positionConstraint = reference.GetComponent <PositionConstraint>(); } source = positionConstraint.GetSource(index); }
// Start is called before the first frame update void Start() { // スタートの位置に移動 this.transform.position = Start_Object.transform.position; // HP設定 hp = MAXHP; // リジッドボディを取得 this.rigid2D = GetComponent <Rigidbody2D>(); this.PosCon = GetComponent <PositionConstraint>(); // 自分の座標を覚えておく(プレハブにしたらいらないかも) m_ini_pos = this.transform.position; this.defaultScale = this.transform.lossyScale; // 音楽の取得 s_reflect = GetComponent <AudioSource>(); }
void Start() { joystickClick.AddOnUpdateListener(joystickClicked, SteamVR_Input_Sources.LeftHand); joystickClick.AddOnUpdateListener(joystickClicked, SteamVR_Input_Sources.RightHand); cameraRig = GameObject.Find("[CameraRig]"); pilot = GameObject.Find("Pilot"); headTarget = GameObject.Find("Head Target for Mech IK"); leftHandTarget = GameObject.Find("Left Hand Target for Mech IK"); rightHandTarget = GameObject.Find("Right Hand Target for Mech IK"); headTargetContraint = headTarget.GetComponent <PositionConstraint>(); leftHandTargetContraint = leftHandTarget.GetComponent <PositionConstraint>(); rightHandTargetContraint = rightHandTarget.GetComponent <PositionConstraint>(); }
private static void LockPosition(PlayerMovement player, Transform carryPoint) { Vector3 carryPosition = carryPoint.position; carryPoint.position = new Vector3( carryPosition.x, player.transform.position.y, carryPosition.z ); PositionConstraint parent = player.gameObject.AddComponent <PositionConstraint>(); parent.AddSource(new ConstraintSource { sourceTransform = carryPoint, weight = 1 }); parent.constraintActive = true; }
public MainPage() { InitializeComponent(); var mainCollection = (ConstraintCollection)Resources["Constraints"]; var altCollection = (ConstraintCollection)Resources["AltConstraints"]; mainCollection.Add(PositionConstraint.CenterX(Toggle).ToCenterX(Layout)); mainCollection.Add(PositionConstraint.CenterY(Toggle).ToCenterY(Layout)); mainCollection.Add(DimensionConstraint.Width(Toggle, -20).ToWidth(Layout, 0.5f)); mainCollection.Add(DimensionConstraint.Height(Toggle, -20).ToHeight(Layout, 0.3f)); altCollection.Add(PositionConstraint.Left(Toggle).ToLeft(LeftLabel)); altCollection.Add(DimensionConstraint.Width(Toggle, 400)); altCollection.Add(PositionConstraint.Top(Toggle).ToBottom(BottomLabel)); altCollection.Add(PositionConstraint.Bottom(Toggle).ToBottom(Layout)); }
void Start() { //プレイヤー(カード)の初期値が入ってから実行したいのでUpdateで1回のみ実行 this.LateUpdateAsObservable().Take(1).Subscribe(_ => SetInitPosition()); //isActiveがfalseならその場で待機 this.UpdateAsObservable().Where(_ => !isActive). Subscribe(_ => this.transform.position = new Vector3(WorkPos.x, PosY, WorkPos.z)); // 追従用の初期化 this.gameObject.AddComponent <PositionConstraint>(); this.myPositionConstaint = GetComponent <PositionConstraint>(); oldPos = Vector3.zero; ChildTransform = null; }
private static void BuildRig() { Transform cam = new GameObject("Camera", new System.Type[3] { typeof(Camera), typeof(AudioListener), typeof(PositionConstraint) }).transform; cam.position = Vector3.zero; PositionConstraint constraint = cam.GetComponent <PositionConstraint>(); // views BuildView("Front", Vector3.zero, Vector3.forward, cam, constraint, 0, 1); BuildView("Down", Vector3.down, Vector3.down, cam, constraint, 1, 0); BuildView("Up", Vector3.up, Vector3.up, cam, constraint, 2, 0); BuildView("Left", Vector3.left, Vector3.left, cam, constraint, 3, 0); BuildView("Right", Vector3.right, Vector3.right, cam, constraint, 4, 0); constraint.constraintActive = true; }
public void StartMatch() { // TextAsset gameJson = Resources.Load(filePath) as TextAsset; // Debug.Log(gameJson); // game = JsonUtility.FromJson<SlippiGame>(gameJson.text); //Debug.Log(game.settings.stageId); foreach (Transform child in world.transform) { GameObject.Destroy(child.gameObject); } if (game == null) { Debug.LogWarning("You need to set a game in order to play it back"); } player1Index = game.settings.players[0].playerIndex; player2Index = game.settings.players[1].playerIndex; string stageName = SlippiLookupTable.GetStageName(game.settings.stageId); string p1Name = SlippiLookupTable.GetCharacterName(game.settings.players[0].characterId); string p2Name = SlippiLookupTable.GetCharacterName(game.settings.players[1].characterId); Debug.Log(stageName); Debug.Log(p1Name); Debug.Log(p2Name); // Load Stage UnityEngine.Object stagePrefab = Resources.Load("StagePrefabs/" + stageName + "/" + stageName); GameObject stage = Instantiate(stagePrefab) as GameObject; stage.transform.parent = world; world.transform.position = new Vector3(0, -1, 7); stage.transform.localPosition = new Vector3(0, 0, 0); stage.transform.eulerAngles = new Vector3(0, 180, 0); // Load Characters UnityEngine.Object p1Prefab = Resources.Load("CharacterPrefabs/" + p1Name + "/" + p1Name); GameObject p1; if (p1Prefab == null) { p1 = GameObject.CreatePrimitive(PrimitiveType.Sphere); } else { p1 = Instantiate(p1Prefab) as GameObject; } Animation _1Animation = p1.AddComponent(typeof(Animation)) as Animation; p1Animation = _1Animation; GameObject p1G = new GameObject(); player1 = p1G.transform; GameObject p2G = new GameObject(); player2 = p2G.transform; player1.parent = world; player2.parent = world; p1.transform.parent = player1; p1.transform.localPosition = new Vector3(0, 0, 0); p1.transform.localScale = new Vector3(100, 100, 100); // Apply Red Material to P1 Material p1Material = Resources.Load("Materials/Player1Material") as Material; foreach (Transform child in p1.transform) { SkinnedMeshRenderer meshRenderer = child.GetComponent <SkinnedMeshRenderer>(); if (meshRenderer == null) { continue; } meshRenderer.sharedMaterial = p1Material; } UnityEngine.Object p2Prefab = Resources.Load("CharacterPrefabs/" + p2Name + "/" + p2Name); GameObject p2; if (p2Prefab == null) { p2 = GameObject.CreatePrimitive(PrimitiveType.Sphere); } else { p2 = Instantiate(p2Prefab) as GameObject; } Animation _2Animation = p2.AddComponent(typeof(Animation)) as Animation; p2Animation = _2Animation; p2.transform.parent = player2; p2.transform.localPosition = new Vector3(0, 0, 0); p2.transform.localScale = new Vector3(100, 100, 100); // Apply Blue Material to P2 Material p2Material = Resources.Load("Materials/Player2Material") as Material; foreach (Transform child in p2.transform) { SkinnedMeshRenderer meshRenderer = child.GetComponent <SkinnedMeshRenderer>(); if (meshRenderer == null) { continue; } meshRenderer.sharedMaterial = p2Material; } // ================= Initiate Shield Stuff UnityEngine.Object shieldPrefab = Resources.Load("CharacterPrefabs/" + p2Name + "/" + p2Name); player1Shield = GameObject.CreatePrimitive(PrimitiveType.Sphere); player2Shield = GameObject.CreatePrimitive(PrimitiveType.Sphere); Material p1ShieldMaterial = Resources.Load("Materials/Player1ShieldMaterial") as Material; Material p2ShieldMaterial = Resources.Load("Materials/Player2ShieldMaterial") as Material; player1Shield.GetComponent <MeshRenderer>().material = p1ShieldMaterial; player2Shield.GetComponent <MeshRenderer>().material = p2ShieldMaterial; player1Shield.transform.parent = p1.transform; player2Shield.transform.parent = p2.transform; player1Shield.name = "Shield"; player2Shield.name = "Shield"; player1Shield.transform.localPosition = new Vector3(0, .07f, 0); player2Shield.transform.localPosition = new Vector3(0, .07f, 0); player1Shield.transform.localScale = new Vector3(.12f, .12f, .12f); player2Shield.transform.localScale = new Vector3(.12f, .12f, .12f); player1Shield.SetActive(false); player2Shield.SetActive(false); // ================ End Shield Stuff DirectoryInfo p1Dir = new DirectoryInfo("Assets/Resources/CharacterPrefabs/" + p1Name + "/Animation/"); FileInfo[] p1files = p1Dir.GetFiles("*.fbx"); foreach (FileInfo f in p1files) { string animationName = Path.GetFileNameWithoutExtension(f.ToString()); AnimationClip clip = Resources.Load <AnimationClip>("CharacterPrefabs/" + p1Name + "/Animation/" + animationName); clip.legacy = true; p1Animation.AddClip(clip, animationName); } // Prepare Animations DirectoryInfo p2Dir = new DirectoryInfo("Assets/Resources/CharacterPrefabs/" + p2Name + "/Animation/"); FileInfo[] p2files = p2Dir.GetFiles("*.fbx"); foreach (FileInfo f in p2files) { string animationName = Path.GetFileNameWithoutExtension(f.ToString()); AnimationClip clip = Resources.Load <AnimationClip>("CharacterPrefabs/" + p2Name + "/Animation/" + animationName); clip.legacy = true; p2Animation.AddClip(clip, animationName); } // Lock Animations for offending objects that change entire model location foreach (Transform child in p1.transform.GetComponentsInChildren <Transform>()) { if (child.name == "JOBJ_1") { PositionConstraint pc = child.gameObject.AddComponent(typeof(PositionConstraint)) as PositionConstraint; ConstraintSource constraintSource = new ConstraintSource(); constraintSource.sourceTransform = child.parent; pc.AddSource(constraintSource); pc.constraintActive = true; } if (child.name == "JOBJ_2") { p1RotationToReset = child; } } ; foreach (Transform child in p2.transform.GetComponentsInChildren <Transform>()) { if (child.name == "JOBJ_1") { PositionConstraint pc = child.gameObject.AddComponent(typeof(PositionConstraint)) as PositionConstraint; ConstraintSource constraintSource = new ConstraintSource(); constraintSource.sourceTransform = child.parent; pc.AddSource(constraintSource); pc.constraintActive = true; } if (child.name == "JOBJ_2") { p2RotationToReset = child; } } ; SlippiPost post1 = game.frames[0].players[player1Index].post; stockHolder = new GameObject("Stocks"); stockHolder.transform.parent = world.transform; player1Stocks = new List <GameObject>(); player2Stocks = new List <GameObject>(); InstantiateStocks(post1.stocksRemaining, 1, p1Material, player1Stocks); InstantiateStocks(post1.stocksRemaining, 2, p2Material, player2Stocks); stockHolder.transform.localScale = new Vector3(5, 5, 2); stockHolder.transform.localPosition = new Vector3(0, 0, -28); player1Stock = post1.stocksRemaining; player2Stock = post1.stocksRemaining; world.localScale = new Vector3(1 * worldScale, 1 * worldScale, 1 * worldScale); matchStarted = true; // Tell Hypersdk players to reload hsdkc = GetComponent <HyperSDKController>(); sceneID++; hsdkc.sceneID = sceneID; }
void Start() { for (int i = 0; i < 32; i++) { if (LayerMask.LayerToName(i) == "Liquid") { layer = i; break; } } anchor = new GameObject(transform.parent.name + "_slosher " + count) { layer = layer, }; anchor.transform.position = transform.position; Rigidbody anchorBody = anchor.AddComponent <Rigidbody>(); anchorBody.mass = 1f; anchorBody.isKinematic = true; anchorBody.useGravity = false; ConfigurableJoint joint = anchor.AddComponent <ConfigurableJoint>(); joint.anchor = Vector3.zero; joint.axis = Vector3.right; joint.autoConfigureConnectedAnchor = false; joint.connectedAnchor = new Vector3(0f, pendulumLength, 0f); joint.secondaryAxis = Vector3.up; joint.xMotion = ConfigurableJointMotion.Locked; joint.yMotion = ConfigurableJointMotion.Locked; joint.zMotion = ConfigurableJointMotion.Locked; joint.angularXMotion = ConfigurableJointMotion.Limited; joint.angularYMotion = ConfigurableJointMotion.Locked; joint.angularZMotion = ConfigurableJointMotion.Limited; SoftJointLimit sjl = joint.lowAngularXLimit; sjl.limit = -liquidAngularLimit; sjl.bounciness = liquidBounciness; joint.lowAngularXLimit = sjl; sjl = joint.highAngularXLimit; sjl.limit = liquidAngularLimit; sjl.bounciness = liquidBounciness; joint.highAngularXLimit = sjl; sjl = joint.angularZLimit; sjl.limit = liquidAngularLimit; sjl.bounciness = liquidBounciness; joint.angularZLimit = sjl; PositionConstraint constraint = anchor.AddComponent <PositionConstraint>(); ConstraintSource source = new ConstraintSource() { weight = 1f, sourceTransform = transform }; constraint.AddSource(source); constraint.locked = true; constraint.constraintActive = true; pendulum = new GameObject(transform.parent.name + "_slosher_pendulum " + count) { layer = layer }; pendulum.transform.position = transform.position - Vector3.down * pendulumLength; Rigidbody pendulumBody = pendulum.AddComponent <Rigidbody>(); pendulumBody.mass = pendulumMass; pendulumBody.drag = pendulumDrag; pendulumBody.useGravity = true; SphereCollider collider = pendulum.AddComponent <SphereCollider>(); collider.radius = 0.01f; joint.connectedBody = pendulumBody; count++; }