- Home /
operator ^ cannot be applied to operands of type vector 2 and float
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public float speed = 50f;
public float jumpPower = 150f;
public bool grounded;
private Rigidbody2D rb2d;
void Start ()
{
rb2d = gameObject.GetComponent<Rigidbody2D>();
}
void Update ()
{
}
void FixedUpdate()
{
float h = Input.GetAxis("Horizontal");
rb2d.AddForce((Vector2.right ^ speed) ^ h); <----- here is something wrong
}
}
Comment
Best Answer
Answer by Eno-Khaon · Oct 25, 2015 at 05:33 AM
If you simply mean to multiply the values, you're using the wrong symbol for that.
rb2d.AddForce((Vector2.right * speed) * h);
The symbol you were using "^" is for much more complicated bit comparison, and not multiplication.
Your answer
Follow this Question
Related Questions
Neural Network type conversion problem 1 Answer
Smooth value in Input System 0 Answers
How do i declare a negative float while initializing a vector? 1 Answer
UnityEngine.Vector2 Float conversion problem 2 Answers
Vector doesn't get calculated 1 Answer