本文整理汇总了C#中UnityEngine.Transform.RotateAround方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.RotateAround方法的具体用法?C# Transform.RotateAround怎么用?C# Transform.RotateAround使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Transform
的用法示例。
在下文中一共展示了Transform.RotateAround方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
void Update()
{
if (data != null) {
Anchor = data.target.position;
postition = data.position;
postition.RotateAround (Anchor, Vector3.up, data.input.position.x * rotateSpeed * Time.deltaTime);
postition.RotateAround (Anchor, Vector3.left, data.input.position.y * rotateSpeed * Time.deltaTime);
}
}
示例2: estouAbrindoAPorta
public static bool estouAbrindoAPorta(Transform porta,Transform baseDaPorta,int deComparacao = 0,int dir = 1)
{
Vector3 V = porta.position-4*Vector3.up;
Vector3 comparavel = vetorComparavel(porta,deComparacao,dir);
if(((int)Vector3.Angle(comparavel,Vector3.up))%7==0)
for(int i = 0;i<5;i++)
{
Destroy(Instantiate(
elementosDoJogo.el.retorna("poeiraAoVento"),
V+i*2*baseDaPorta.up,
Quaternion.identity
),2);
Destroy(Instantiate(
elementosDoJogo.el.retorna("poeiraAoVento"),
V-i*2*baseDaPorta.up,
Quaternion.identity
),2);
}
if(Vector3.Angle(comparavel,Vector3.up)>1)
porta.RotateAround(baseDaPorta.position,
(deComparacao==0)?-baseDaPorta.forward : baseDaPorta.up,dir*25*Time.deltaTime);
else{
return false;
}
return true;
}
示例3: RotateWhitTarget1
public static void RotateWhitTarget1(Transform transform, Transform target, Vector3 direction, float theta, float t)
{
Vector3 Axis = Vector3.Cross(direction, transform.position - target.position);
Axis = Axis;
Debug.DrawRay(transform.position, Axis, Color.green);
Debug.DrawRay(transform.position, direction, Color.blue);
transform.RotateAround(Axis, theta / Mathf.PI * 180f);
}
示例4: Start
// Use this for initialization
void Start () {
// can't use GetComponentInChildren because it'll just pull the transform from the parent :I
foreach (Transform childTransform in transform) {
imageTransform = childTransform;
}
// added random rotation on start to add variety
imageTransform.RotateAround(transform.position, Vector3.forward, Random.Range(1, 50));
}
示例5: _plantgrass
static void _plantgrass(Transform grassTransform)
{
RaycastHit hitInfo = new RaycastHit();
int layermask = 1 << LayerMask.NameToLayer("Terrain");
if (Physics.Raycast(grassTransform.position, Vector3.down, out hitInfo, 1000, layermask))
{
grassTransform.position = hitInfo.point;
grassTransform.RotateAround(Vector3.up, Random.Range(0f, 360f));
}
}
示例6: estouFechandoAPorta
public static bool estouFechandoAPorta(Transform porta,Transform baseDaPorta,int deComparacao = 0,int dir = 1)
{
Vector3 comparavel = vetorComparavel(porta,deComparacao,dir);
if(Vector3.Angle(comparavel,Vector3.up)<90)
porta.RotateAround(baseDaPorta.position,baseDaPorta.up,-dir*25*Time.deltaTime);
else{
return false;
}
return true;
}
示例7: Start
// Use this for initialization
void Start()
{
Vector3 turretPos = transform.localPosition;
halfTurretLength = transform.localScale.x/2;
float halfBeamLength = beamLength/2;
// Create detector beam
beam = (Transform) Instantiate(beam);
switch (direction) {
case Direction.up :
beamPosition = turretPos + new Vector3 (0, 0, halfBeamLength + halfTurretLength);
beam.RotateAround(beamPosition, Vector3.up, 90);
break;
case Direction.right :
beamPosition = turretPos + new Vector3 (halfBeamLength + halfTurretLength, 0, 0);
break;
case Direction.down :
beamPosition = turretPos + new Vector3 (0, 0, - halfBeamLength - halfTurretLength);
beam.RotateAround(beamPosition, Vector3.up, 90);
break;
case Direction.left :
beamPosition = turretPos + new Vector3 (- halfBeamLength - halfTurretLength, 0, 0);
break;
}
beam.localScale = new Vector3 (2, halfBeamLength, 2);
beam.localPosition = beamPosition;
// set all things as a child
beam.parent = transform;
SetState ();
}
示例8: RotateObjectRelative
// This allows you to rotate an object on screen by a change in screen rotation, relative to a point on the screen
public static void RotateObjectRelative(Transform transform, float deltaRotation, Vector2 referencePoint, Camera camera = null)
{
if (transform != null && deltaRotation != 0.0f)
{
if (camera == null) camera = Camera.main;
if (camera != null)
{
transform.RotateAround(camera.ScreenToWorldPoint(referencePoint), camera.transform.forward, deltaRotation);
}
}
}
示例9: RotatePartPointAngle
// rotate an object fix amount per frame
// degree per frame : 1f
// axis of rotation : Vector3.forward
float RotatePartPointAngle(Transform part, Vector3 point, float angle, float aor)
{
float sign;
sign = angle/Mathf.Abs(angle);
if (aor < Mathf.Abs(angle))
{
part.RotateAround(point, Vector3.forward, sign*1f);
aor += 1f;
}
return aor;
}
示例10: placeLocal2d
public void placeLocal2d( Transform transform, float ratio )
{
transform.localPosition = point( ratio );
ratio += 0.001f;
if(ratio<=1.0f){
float angle = Vector3.Angle(transform.localPosition, transform.parent.TransformPoint( point( ratio ) ) - transform.localPosition );
transform.rotation = Quaternion.identity;
transform.RotateAround(transform.position, Vector3.up, 90.0f);
transform.RotateAround(transform.position, Vector3.right, angle);
}
}
示例11: DoItem
protected override void DoItem()
{
// Debug.LogWarning("[DoItem]");
ActuallyUsingItem();
SoundManager.Instance.PlayOneShot("sword_sfx");
swordEffectInstance = (Instantiate(effectPrefab) as GameObject).transform;
swordEffectInstanceLama = swordEffectInstance.GetChild(0);
swordAnimation = swordEffectInstanceLama.GetComponentInChildren<Animation>();
int rotateDirection = Vector3.Dot(Vector3.right, swipeDirecion) > 0 ? 1 : -1;
swordEffectInstance.position = startPosition;
swordEffectInstanceLama.rotation = Quaternion.LookRotation(rotateDirection * swipeDirecion.normalized);
Vector3 newRot = swordEffectInstanceLama.localEulerAngles;
newRot.y = 90f;
swordEffectInstanceLama.localEulerAngles = newRot;
swordEffectInstance.RotateAround(swordEffectInstance.position, swipeDirecion, -rotateDirection * 25f);
swordCollision = swordEffectInstance.GetComponent<SwordCollision>();
swordCollision.OnTargetDestroyed += ActionOnTileDestroyed;
if(rotateDirection == 1)
{
swordAnimation["effect_swordswing"].speed = 1f;
swordAnimation.Play("effect_swordswing");
}
else
{
swordAnimation["effect_swordswing"].speed = -1f;
swordAnimation["effect_swordswing"].normalizedTime = 1f;
swordAnimation.Play("effect_swordswing");
}
positionTweener = HOTween.To(swordEffectInstance.transform, swordMovementSpeed,
new TweenParms().Prop("position", endPosition)
.Ease(EaseType.Linear)
.SpeedBased()
.OnComplete(ActionOnTweenComplete)
);
}
示例12: Start
// Use this for initialization
void Start()
{
Vector3 turretPos = transform.localPosition;
halfTurretLength = transform.localScale.x/2;
float halfDetectorLength = detectorLength/2;
// Create detector beam
detector = (Transform) Instantiate(detector);
// Create laser beam
laser = (Transform) Instantiate(laser);
// Create origin and end points
GameObject origin = new GameObject("Laser Shot Origin");
GameObject end = new GameObject("Laser Shot End");
switch (direction) {
case Direction.up :
detectorPosition = turretPos + new Vector3 (0, 0, halfDetectorLength + halfTurretLength);
detector.RotateAround(detectorPosition, Vector3.up, 90);
laserPosition = turretPos + new Vector3 (0, 0, halfTurretLength/2);
laser.RotateAround(laserPosition, Vector3.up, 90);
origin.transform.localPosition = turretPos;// + new Vector3 (0, 0, halfTurretWidth);
end.transform.localPosition = turretPos + new Vector3 (0, 0, halfDetectorLength * 2 + halfTurretLength);
break;
case Direction.right :
detectorPosition = turretPos + new Vector3 (halfDetectorLength + halfTurretLength, 0, 0);
laserPosition = turretPos + new Vector3 (halfTurretLength/2, 0, 0);
origin.transform.localPosition = turretPos;// + new Vector3 (halfTurretWidth, 0, 0);
end.transform.localPosition = turretPos + new Vector3 (halfDetectorLength * 2 + halfTurretLength, 0, 0);
break;
case Direction.down :
detectorPosition = turretPos + new Vector3 (0, 0, - halfDetectorLength - halfTurretLength);
detector.RotateAround(detectorPosition, Vector3.up, 90);
laserPosition = turretPos + new Vector3 (0, 0, -halfTurretLength/2);
laser.RotateAround(laserPosition, Vector3.up, 90);
origin.transform.localPosition = turretPos;// + new Vector3 (0, 0, - halfTurretWidth);
end.transform.localPosition = turretPos + new Vector3 (0, 0, - halfDetectorLength * 2 - halfTurretLength);
break;
case Direction.left :
detectorPosition = turretPos + new Vector3 (- halfDetectorLength - halfTurretLength, 0, 0);
laserPosition = turretPos + new Vector3 (-halfTurretLength/2, 0, 0);
origin.transform.localPosition = turretPos;// + new Vector3 (- halfTurretWidth, 0, 0);
end.transform.localPosition = turretPos + new Vector3 (- halfDetectorLength * 2 - halfTurretLength, 0, 0);
break;
}
detector.localScale = new Vector3 (1, halfDetectorLength, 1);
detector.localPosition = detectorPosition;
laser.localScale = new Vector3 (2, halfTurretLength/2, 2);
laser.localPosition = laserPosition;
laser.GetComponent<LaserShot>().origin = origin;
laser.GetComponent<LaserShot>().end = end;
// set all things as a child
detector.parent = transform;
laser.parent = transform;
origin.transform.parent = transform;
end.transform.parent = transform;
}
示例13: Move
public override void Move(float x, float y, float horizontalSpeed, float verticalSpeed, Transform transform, float deltaTime)
{
transform.RotateAround (moveAround, transform.forward, -x * deltaTime * horizontalSpeed);
}
示例14: Move
protected void Move(Transform tourelle, Transform head = null, Transform look_point = null, Vector3 target = default(Vector3))
{
if (Auto)
{
float speed = 1f;
Transform t = GetTarget();
if (t != null)
speed = t.gameObject.GetComponent<Enemy>().Speed;
if (target == Vector3.zero)
{
if(t != null)
target = t.position;
}
if (target != Vector3.zero)
{
// Find the vector pointing from our position to the target
_direction = (target - (look_point != null ? look_point.position : head != null ? head.position : tourelle.position)).normalized;
// Create the rotation we need to be in to look at the target
_lookRotation = Quaternion.LookRotation(_direction);
// Rotate us over time according to speed until we are in the required rotation
speed = speed * 10f;
if (Quaternion.Angle(tourelle.rotation, _lookRotation) < 5f)
speed *= 2f;
tourelle.rotation = Quaternion.Slerp(tourelle.rotation, _lookRotation, Time.deltaTime * speed);
if (head != null)
{
tourelle.rotation = Quaternion.Euler(new Vector3(0f, tourelle.rotation.eulerAngles.y, 0f));
head.rotation = Quaternion.Slerp(head.rotation, _lookRotation, Time.deltaTime * speed);
}
}
}
else
{
Transform h = (head != null ? head : tourelle.FindChild("Cannon"));
Vector3 dir = (h.position - _camera.position);
if (Input.GetKey(KeyCode.Z) && _angleRotation < 90f)
{
_angleRotation += DeltaRot * RotationSpeed;
if(head != null)
head.Rotate(new Vector3(DeltaRot * RotationSpeed, 0, 0));
else
tourelle.Rotate(new Vector3(DeltaRot * RotationSpeed, 0, 0));
}
else if (Input.GetKey(KeyCode.S) && _angleRotation > -45f)
{
_angleRotation -= DeltaRot * RotationSpeed;
if (head != null)
head.Rotate(new Vector3(-DeltaRot * RotationSpeed, 0, 0));
else
tourelle.Rotate(new Vector3(-DeltaRot * RotationSpeed, 0, 0));
}
if (Input.GetKey(KeyCode.D))
tourelle.RotateAround(tourelle.position, new Vector3(0, 1, 0), DeltaRot * RotationSpeed);
else if (Input.GetKey(KeyCode.Q))
tourelle.RotateAround(tourelle.position, new Vector3(0, 1, 0), -DeltaRot * RotationSpeed);
Vector3 aim = h.position + h.transform.forward * 5f;
Quaternion cam_look = Quaternion.LookRotation((aim - _camera.position).normalized);
Vector3 cam_pos = h.position - dir.magnitude * h.forward;
float speed = 5f;
_camera.rotation = Quaternion.Slerp(_camera.rotation, cam_look, Time.deltaTime * speed);
_camera.position = Vector3.Slerp(_camera.position, cam_pos + _camera.up, Time.deltaTime * speed);
}
}
示例15: update
//.........这里部分代码省略.........
else
{
trans.localPosition = tween.spline.point(val);
}
}
else if (tweenAction == TweenAction.SCALE_X)
{
trans.localScale = new Vector3(val, trans.localScale.y, trans.localScale.z);
}
else if (tweenAction == TweenAction.SCALE_Y)
{
trans.localScale = new Vector3(trans.localScale.x, val, trans.localScale.z);
}
else if (tweenAction == TweenAction.SCALE_Z)
{
trans.localScale = new Vector3(trans.localScale.x, trans.localScale.y, val);
}
else if (tweenAction == TweenAction.ROTATE_X)
{
trans.eulerAngles = new Vector3(val, trans.eulerAngles.y, trans.eulerAngles.z);
}
else if (tweenAction == TweenAction.ROTATE_Y)
{
trans.eulerAngles = new Vector3(trans.eulerAngles.x, val, trans.eulerAngles.z);
}
else if (tweenAction == TweenAction.ROTATE_Z)
{
trans.eulerAngles = new Vector3(trans.eulerAngles.x, trans.eulerAngles.y, val);
}
else if (tweenAction == TweenAction.ROTATE_AROUND)
{
Vector3 origPos = trans.localPosition;
Vector3 rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
trans.RotateAround(rotateAroundPt, tween.axis, -val);
Vector3 diff = origPos - trans.localPosition;
trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
trans.rotation = tween.origRotation;
rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
trans.RotateAround(rotateAroundPt, tween.axis, val);
//GameObject cubeMarker = GameObject.Find("TweenRotatePoint");
//cubeMarker.transform.position = rotateAroundPt;
}
else if (tweenAction == TweenAction.ROTATE_AROUND_LOCAL)
{
Vector3 origPos = trans.localPosition;
trans.RotateAround((Vector3)trans.TransformPoint(tween.point), trans.TransformDirection(tween.axis), -val);
Vector3 diff = origPos - trans.localPosition;
trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
trans.localRotation = tween.origRotation;
Vector3 rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
trans.RotateAround(rotateAroundPt, trans.TransformDirection(tween.axis), val);
//GameObject cubeMarker = GameObject.Find("TweenRotatePoint");
//cubeMarker.transform.position = rotateAroundPt;
}
else if (tweenAction == TweenAction.ALPHA)
{
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
if(trans.gameObject.renderer){