[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/wsr/ - Worksafe Requests

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


Janitor application acceptance emails are being sent out. Please remember to check your spam box!


[Advertise on 4chan]


File: Warrior_Blue.png (82 KB, 1152x1536)
82 KB
82 KB PNG
I'm trying to figure out why my character isn't moving. I've followed multiple tutorials online with no success. My character never moves.

Can I get some help with what is going on?

When I put in rb.velocity = new Vector2(horizontal, vertical); it strikes a line through velocity, or force updates to "angularVelocity" and nothing moves. Using Unity 6.2. What's going on?

Error CS0029: Cannot implicitly convert type 'UnityEngine.Vector2' to 'float'

using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerMovement : MonoBehaviour
{
public float speed = 5;
public Rigidbody2D rb;

void Update()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");

rb.velocity = new Vector2(horizontal, vertical);
}
}
>>
Try using linearVelocity instead of velocity.
It's been a while since I've used unity. From looking at the scripting documentation unity has deprecated and gotten rid of the velocity variable in Rigidbody2d some time ago and replaced it with linearVelocity. Why? I dunno.

When assigning angular velocity a value i suspect you are giving it the wrong type of value. Angular velocity has the type float and only be assigned floats. If you try to assign a Vector2 it will give you the error in your post.

WSR is not the place I would go to for help with game dev programming. In the future try >>>/g/dpt/ >>>/g/sqt/ or >>>/vg/agdg/



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.