- Home /
HOW TO INTEGRATE WEBCAM AND TEACHABLE MACHINE MODEL
I want to make a simple 2D game in which my player (square) is jumping when I do Class1 from my TeachableMachine model. My model has two classes- first one is jump (he recognize that I jumped in front off my webcam) and other one is doing anything else except jump. That means that I need to include camera in my c# script and then add model with link that I have and after that add an classifier and some condition like if(classifier == class1) JUMP; I have script down there, my player is constantly moving forward and jumps when I click on Space key. PLEASE HELP ME <3
MY SCRIPT :::::
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class kretanje : 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();
}
}
Your answer
Follow this Question
Related Questions
Possible To Add Move Functions To Camera? 2 Answers
Mini cam/duplicate of main camera view 0 Answers
How to get the 2d Poisition (in camera) of the mesh vertices 3 Answers
Camera wrapping 0 Answers
Unpaused camera twitch 0 Answers