I am using CreateJS in the RAF mode
createjs.Ticker.timingMode = createjs.Ticker.RAF;
How do I integrate with for instance stats.js measure the browser's FPS?
Or is there any different, recommended way to measure the FPS with CreateJS?
Thanks!
You should be able to integrate using the instructions on the stats.js GitHub page
Essentially:
c.Ticker.on("tick", tick, this);
function tick(evt) {
stats.begin();
// do stuff, like stage.update();
stats.end();
}
Alternatively, you could look at Ticker.getMeasuredFPS and Ticker.getMeasuredTickTime.
Related
I am using the A* graph package that I found here.
https://arongranberg.com/astar/download
it all works well in scene view and I was able to set the graph to treat walls like obstacles.
However once I start the game the canvas scales and the graph's nodes no longer align with the walls.
this is really messing up my path finding. If anyone has any ideas how to fix this that would be much appreciated. I tried parenting the graph to the canvas but it still doesn't scale.
Kind regards
For anyone struggling with this what we did is edited the script of the A* code, in the update function we just got it to rescan once. This means that once the game started and all the scaling had taken place the graph re adjusted its bounds. This is probably not the most proper way but it only took four lines and worked for us.
private bool scanAgain = true;
private void Update () {
// This class uses the [ExecuteInEditMode] attribute
// So Update is called even when not playing
// Don't do anything when not in play mode
if (!Application.isPlaying) return;
navmeshUpdates.Update();
// Execute blocking actions such as graph updates
// when not scanning
if (!isScanning) {
PerformBlockingActions();
}
// Calculates paths when not using multithreading
pathProcessor.TickNonMultithreaded();
// Return calculated paths
pathReturnQueue.ReturnPaths(true);
if (scanAgain)
{
Scan();
scanAgain = false;
}
I need to get the Color and Depth frames from an XEF file recorded using Kinect Studio.
My code for accessing the Color and Depth frames when using the Kinect directly looks like this:
_sensor = KinectSensor.GetDefault();
if (_sensor != null)
{
_sensor.Open();
_reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
_reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;
_coordinateMapper = _sensor.CoordinateMapper;
}
In private void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e) I do my magic, which works.
Now how do I go about that using a pre-recorded XEF file?
I got that I can load an XEF file like this:
var kStudioClient = KStudio.CreateClient();
var eventFile = kStudioClient.OpenEventFile(#"D:\Kinect Studio Recordings\20170922_083134_00.xef");
But how can I get a MultiSourceFrame from that?
Any help is greatly appreciated! Thanks!
You are on the right track with the KStudioClient API. If you haven't implemented it yourself already, there is also a KStudioPlayback class you should use to play back XEF clips asynchronously. I will not explain and give you exact code how to playback at this stage - the API is very easy to understand. Correct usage of this class will issue MultiSourceFrameArrived events automatically, so you do now need to change the way you handle them.
Here is everything you need to know to get up to speed with the KStudioPlayback class - KStudioPlayback class API. If you need code samples, post a comment, and I will get back to you.
I am writing some editor extensions which setup big complex mechanim blend trees and state machines. I have no problem creating layers, states, and attaching motions to blend trees via editor scripts, etc...
However, I can not find any calls that allow me to setup a Motion's speed setting. Is this possible?
While there's no direct API call to set the speed of a motion in a blend tree it is possible to do so via Unity's SerializedObject/SerializedProperty API. Something like this ought to do it:
var serialised = new SerializedObject(blendTree);
var children = serialised.FindProperty("m_Childs");
var child = children.GetArrayElementAtIndex(0);
var timeScale = child.FindPropertyRelative("m_TimeScale");
timeScale.floatValue = speed;
serialised.ApplyModifiedProperties();
I think what you're looking for is AnimatorState.speedParameter :
https://docs.unity3d.com/ScriptReference/Animations.AnimatorState-speedParameter.html
This thread show how to use it and has also interesting workarounds in case it's not enough https://forum.unity3d.com/threads/mecanim-change-animation-speed-of-specific-animation-or-layers.160395/page-2
I currently am using Max/MSP to create an interactive system between lights and sound.
I am using Philips hue lighting which I have hooked up to Max/MSP and now I am wanting to trigger an increase in brightness/saturation on the input of a note from a Midi instrument. Does anyone have any ideas how this might be accomplished?
I have built this.
I used the shell object. And then feed an array of parameters into it via a javascipt file with the HUE API. There is a lag time of 1/6 of a second between commands.
Javascript file:
inlets=1;
outlets=1;
var bridge="192.168.0.100";
var hash="newdeveloper";
var bulb= 1;
var brt= 200;
var satn= 250;
var hcolor= 10000;
var bulb=1;
function list(bulb,hcolor,brt,satn,tran) {
execute('PUT','http://'+bridge+'/api/'+hash+'/lights/'+bulb+'/state', '"{\\\"on\\\":true,\\\"hue\\\":'+hcolor+', \\\"bri\\\":'+brt+',\\\"sat\\\":'+satn+',\\\"transitiontime\\\":'+tran+'}"');
}
function execute($method,$url,$message){
outlet(0,"curl --request",$method,"--data",$message,$url);
}
To control Philips Hue you need to issue calls to a restful http based api, like so: http://www.developers.meethue.com/documentation/core-concepts, using the [jweb] or [maxweb] objects: https://cycling74.com/forums/topic/making-rest-call-from-max-6-and-saving-the-return/
Generally however, to control lights you use DMX, the standard protocol for professional lighting control. Here is a somewhat lengthy post on the topic: https://cycling74.com/forums/topic/controlling-video-and-lighting-with-max/, scroll down to my post from APRIL 11, 2014 | 3:42 AM.
To change the bri/sat of your lights is explained in the following link (Registration/Login required)
http://www.developers.meethue.com/documentation/lights-api#16_set_light_state
You will need to know the IP Address of your hue hue bridge which is explained here: http://www.developers.meethue.com/documentation/getting-started and a valid username.
Also bear in mind the performance limitations. As a general rule you can send up to 10 lightstate commands per second. I would recommend having a 100ms gap between each one, to prevent flooding the bridge (and losing commands).
Are you interested in finding out details of who to map this data from a MIDI input to the phillips HUE lights within max? or are you already familiar with Max.
Using Tommy b's javascript (which you could put into a js object), You could for example scale the MIDI messages you want to use using midiin and borax objects and map them to the outputs you want using the scale object. Karlheinz Essl's RTC library is a good place to start with algorithmic composition if you want to transform the data at all http://www.essl.at/software.html
+1 for DMX light control via Max. There are lots of good max-to-dmx tutorials and USB-DMX hardware is getting pretty cheap. However, as someone who previously believed in dragging a bunch of computer equipment on stage just to control a light or two with an instrument, I'd recommend researching and purchasing a simple one channel "color organ" circuit kit (e.g., Velleman MK 110). Controlling a 120/240V light bulb via audio is easier than you might think; a computer for this type of application is usually overkill. Keep it simple and good luck!
I'm building my first game in Unity using my limited knowledge, youtube tutorials and troubleshooting on google and even though i have a couple of idea's on how i could do this i can't seem to get it to work.
For one of the larger levels i need speedups that boost the players speed when driving over them. This is seen in a lot of racing games but to clarify i found this video where this type of boosters is used https://www.youtube.com/watch?v=GQ1FLPBw1FE.
I've tried making a script that would remove my current movementscript and replace it with a faster one, i've also tried making a script that would detect collision with the player(tag) and add force to it. Both didn't work i've also been thinking about using timescale but i don't want the rest of the world or scorecounters etc to speed up, just the player.
this is the basic script i am using for playermovement.
#pragma strict
function Start () {
}
var forwardSpeed:float = 35;
var turnSpeed:float = 1;
function FixedUpdate () {
var forwardMoveAmount=Input.GetAxis("Vertical")*forwardSpeed;
var turnAmount=Input.GetAxis("Horizontal")*turnSpeed;
transform.Rotate(0,turnAmount,0);
rigidbody.AddRelativeForce(0,0,-forwardMoveAmount);
}
and since the player's vehicle is customizable i also want to make an upgrade that permanently increases the players base movement speed by a certain amount. i would do this by putting in an if(upgrade is active)
increase its speed by x;
this would have to stack with the booster
if you guys have any idea's on how i could do either or both of these things please share and thanks a lot in advance!
Instead of replacing the movement script with a faster one, add in an extra variable to the players movement.
var forwardMoveAmount=Input.GetAxis("Vertical")*forwardSpeed * boostSpeed;
Where boostSpeed regularly equals 1, but when the player collides with a speed boost push the value up to something higher like 2, then after a short while it gets reset to 1. As for the player speed upgrade, follow the same logic, except permanently, so it would look something like this:
var forwardMoveAmount=Input.GetAxis("Vertical")*forwardSpeed * boostSpeed * upgradeSpeed;