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 ::: ********************************************
-
include WebCam
-
include my model using link : Teachable Machine
-
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 :
Machine Learning For Web: Final – dylan dawkins blog
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();
}
}