- Home /
TEACHABLE MACHINE MODEL & UNITY
Hello, I have a "little" struggle here. My problem is that I am not good with C# or Java. I'll appreciate very much if somebody helps me with my little project that I can't attach but I can send in e-mail. I want to integrate TM model in simple UNITY 2D game. I made a Teachable Machine Model (Tensorflow PoseNet Model) that recognize Jumping-Jack pose (class1) and everything that is not Jumping-Jack pose (Class2). Input is from WebCam (LIVE). My model is on picture below :
Game is very simple. On PLAY mode my player is moving constantly and when I press "space" key, player jumps. (picture below)
I need to ::: 1. include WebCam 2. include my model using link : https://teachablemachine.withgoogle.com/models/JXKFF-drd/
add variable "Classifier" with labels class1 / class2
change condition: " if(space is pressed) DO JUMP " in " if (classifier == "class1") DO JUMP "
Here are some links that might help to someone who is better with C# and Java than I am : https://dylandawkinsblog.wordpress.com/2019/05/08/machine-learning-for-web-final/ https://www.youtube.com/watch?v=UPgxnGC8oBU
This is a code that I have so far - Script is attached:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class kretanje1 : MonoBehaviour { Rigidbody2D rb;
// Player Movement Variables/....
public static int movespeed = 3;
public Vector3 userDirection = Vector3.right;
public float jumpForce;
void Start() // Start is called before the first frame update
{
rb = GetComponent<Rigidbody2D>();
}
void Jump()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
}
}
void Update() // Update is called once per frame
{
transform.Translate(userDirection * movespeed * Time.deltaTime);
Jump();
}
}
Answer by UnderShad · Dec 03, 2020 at 09:04 PM
I tried implementing tensor flow in unity but above the unity own ML Agents things get very difficult to implement. May be you can use backend api to send data from the model to realtime database using firebase and link firebase to unity.
Your answer
Follow this Question
Related Questions
The model looks smooth. 0 Answers
How to create 3d models for game and how to add them to game 2 Answers
Wireframe model without faces 2 Answers
MMD How to export model and animations to Unity as 3rd person controller? 2 Answers
imported 3D models don't batch. 0 Answers