Web Player Demo / Watch on YouTube
- See README_EN.txt for further information.
- 日本語の説明はREADME_JP.txtをご覧ください。
- 技術的な解説はWikiをご覧ください。
Unity-Chan "Candy Rock Star" Live Demo
Home Page: http://unity-chan.com/events/c86/WebPlayer/
Web Player Demo / Watch on YouTube
//
//SpringBone.cs for unity-chan!
//
//Original Script is here:
//ricopin / SpringBone.cs
//Rocket Jump : http://rocketjump.skr.jp/unity3d/109/
//https://twitter.com/ricopin416
//
//Revised by N.Kobayashi 2014/06/20
// Revised by ken, 2019/9/19, fixed fps related issue.
//
using UnityEngine;
using System.Collections;
namespace UnityChan
{
public class SpringBone : MonoBehaviour
{
//次のボーン
public Transform child;
//ボーンの向き
public Vector3 boneAxis = new Vector3(-1.0f, 0.0f, 0.0f);
public float radius = 0.05f;
//各SpringBoneに設定されているstiffnessForceとdragForceを使用するか?
public bool isUseEachBoneForceSettings = true;
//バネが戻る力
public float stiffnessForce = 0.01f;
//力の減衰力
public float dragForce = 0.4f;
public Vector3 springForce = new Vector3(0.0f, -0.0001f, 0.0f);
public SpringCollider[] colliders;
public bool debug = true;
//Kobayashi:Thredshold Starting to activate activeRatio
public float threshold = 0.01f;
private float springLength;
private Quaternion localRotation;
private Transform trs;
private Vector3 currTipPos;
private Vector3 prevTipPos;
//Kobayashi
private Transform org;
//Kobayashi:Reference for "SpringManager" component with unitychan
private SpringManager managerRef;
public void Awake()
{
trs = transform;
localRotation = transform.localRotation;
managerRef = GetComponentInParent<SpringManager>();
}
public void OnEnable()
{
//Kobayashi:Reference for "SpringManager" component with unitychan
// GameObject.Find("unitychan_dynamic").GetComponent<SpringManager>();
springLength = Vector3.Distance (trs.position, child.position);
currTipPos = child.position;
prevTipPos = child.position;
}
/// <summary>
/// Update by ken.
/// alteration fps related to time related.
/// </summary>
public void UpdateSpring()
{
const float FORCE_SCALE = 1000f;
const float SPEED_SCALE = 10;
var toPrev = currTipPos - prevTipPos;
var dt = Time.deltaTime;
var force = trs.rotation * (boneAxis * stiffnessForce) * FORCE_SCALE;
force += -toPrev * dragForce * FORCE_SCALE * dt;
force += springForce * FORCE_SCALE * dt;
prevTipPos = currTipPos;
currTipPos += (toPrev + force *0.1f)* SPEED_SCALE * dt;
currTipPos = trs.position + (currTipPos - trs.position).normalized * springLength;
currTipPos = CheckColliders(currTipPos);
var aimDir = trs.TransformDirection(boneAxis);
var aimRot = Quaternion.FromToRotation(aimDir, currTipPos - trs.position);
//trs.rotation = aimRot * trs.rotation;
trs.rotation = Quaternion.Lerp(trs.rotation, aimRot * trs.rotation,managerRef.dynamicRatio);
}
Vector3 CheckColliders(Vector3 currTipPos)
{
for (int i = 0; i < colliders.Length; i++)
{
if (Vector3.Distance(currTipPos, colliders[i].transform.position) <= (radius + colliders[i].radius))
{
Vector3 normal = (currTipPos - colliders[i].transform.position).normalized;
currTipPos = colliders[i].transform.position + (normal * (radius + colliders[i].radius));
currTipPos = ((currTipPos - trs.position).normalized * springLength) + trs.position;
}
}
return currTipPos;
}
private void OnDrawGizmos()
{
if (debug)
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(currTipPos, radius);
}
}
}
}
Hi guys, @keijiro,
Hope you are all well !
I was wondering if there is a GoogleVR demo of Unity Chan - Candy Rock Star with the stage or with the Gyro mode (https://github.com/keijiro/unitychan-crs-gyrocam).
That would be awesome, I tried to port the oculus version but cameras are not working properly on iOS.
Do you have any ready example or insights to share to create such demo ?
Cheers,
Luc
#7 こちらのPRにもある通り、概要欄とREADME.MD 上のリンクに誤りがあるかと思います。
現在のリンク : http://unity-chan.com/events/c86/WebPlayer/
正しいリンク : http://unity-chan.com/event/c86/WebPlayer/
また、README.MD のスクリーンショットも同様にNot Foundが発生しています。
https://camo.githubusercontent.com/07f919b41cb03380f736646d3524166400d24d9c/687474703a2f2f756e6974792d6368616e2e636f6d2f626c6f672f77702d636f6e74656e742f75706c6f6164732f323031342f30382f756e697465696e746865736b795f73732e6a7067
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.