J
J
jdanilaj2021-06-18 15:33:35
Unity
jdanilaj, 2021-06-18 15:33:35

How to make a variable change value depending on object coordinates?

You need to make the facingRight variable change to false if the coordinates of char1 by Scale = -1, 1
A, it gives me an error: Cannot implicitly convert the type "UnityEngine.Vector3" to "bool"

Here is the code:
if (char1.transform. localScale = new Vector2(-1 ,1))
{
Shon.facingRight = !Shon.facingRight;
}

Answer the question

In order to leave comments, you need to log in

6 answer(s)
V
Vitaly Kachan, 2021-06-18
@MANAB

= is assignment, comparison is ==

M
MrSlowpoke, 2021-06-18
@MrSlowpoke

Inside the if is an assignment, not a check. The first step is to change "=" to "=="

Y
youlose, 2012-07-24
@youlose

1. The description of the task is not very clear, can you give an example of the data in these tables and the desired result?
2. “the set of categories is wider” - is this where the number of categories of the device is greater than that of the object?

A
Anatoly, 2012-07-24
@taliban

Here's the pseudocode for you:

FROM devices_categories
LEFT JOIN object_categories on ...
GROUP BY devices_categories... HAVING count(object_categories...) = 0

A
Alexander Korotkov, 2012-07-25
@smagen

You can do this with arrays:

SELECT
  "deviceId"
FROM
  devices_categories
GROUP BY
  "deviceId"
HAVING
  array_agg("catId") @> (
    SELECT
      array_agg("categoryId")
    FROM
      object_categories
    WHERE "objectId" = $1);

In addition, if instead of (or in addition to) devices_categories we make an array of catIds in the device table, then we can build a GIN index on it, and such a query will run very quickly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question