Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

(Solved) How to waste your Time searching for a bug when there s none

A topic by Kucei created Feb 15, 2021 Views: 350 Replies: 9
Viewing posts 1 to 6
(4 edits)

Edit : And this guys is How I waste My time in game Jam
Hello guys, it s me, you probably already know me for my  0% submission rate at game jams so far.

Just Kidding.

So I have a problem and I m not sure How to research my answer in Google so I thought I could give it a try here.

So I have a empty GameObject which is supposed to move in FixedUpdate using the simple code below.

Further ahead I have a trigger wich set StopMoving to true.
My problem is that before the objects even start moving StopMoving becomes trues, as if it was moving really fast on the whole "map" triggering everything that can be, before starting the game at (0,0,0 ).

The thing is I already encountered this problem in a previous project also using transform.right to move my gameobject, at the time I was thinking it might be due to a bad script execution order.
In this previous project my main character went and took damage from every single ennemy before the game even started.
That or he took a few hits from a single ennemy.
The difference between these two options is :
1: the object doesnt teleport but move really fast and trigger everything in its path.
2: The object tp in a spot then is reset.

I think it s option 1 because in this project my ennemies had a cooldown for every attack.

Anyway in this previous project the problem appeared very late in the developpement while it appearded early on this prototype, furthermore, removing then replacing the trigger in the scene seems to have make things work as you can see here :

The object moves then stops when it reaches the trigger as it was intended to.
If you guys know what is the cause of this problem so I can avoid it in the future it would be appreciated.


I was thinking that maybe it was related to my use of Time.deltaTime since in the few examples using transform.right people wern't using it, but it s just a blind guess from a guy with very little knowledge.
I hope you can help me, and also that yo re having a fun Jam.


Edit : Ok, I don't know why I didn't say that but my empty GameObject is parent of another object wich has a rigidbody wich allow me to trigger the "stopMoving" . I talked only about the empty one because the rigidbody is moving by following his parent. But it could be that the child is the one who move independantly and trigger the "StopMoving".

(1 edit)

Update: Actually when I replaced my trigger in the scene it was at a different position, (35,2,0) when I change its position to the old one (23,0,0) the problem occur once again.


When its (35,0,0)


When its (23,0,0)

(1 edit) (+2)

Try using Physics.OverlapCircle() for your trigger. Overlapping returns a boolean of whether or not something is touching it, meaning that you don't need to use OnTriggerEnter. (NOTE: Use Physics2D if you are in 2D)

You could also try using Vector3 (or 2).right instead of transform.right

Thanks for your answer, I m not familiar with the OverlapCircle so I migth be mistaking but are you telling me to use it because I said my gameObject was empty ?

Because .. Yeah don't know why I didnt talk about it but the GO is parent of another one which has a RigidBody and is responsible of triggering the boxcollider wich set "stopMoving" to true.  So yeah im not sure if you talked about that because of my mistake not mentionning the rigidbody, or if there could be a solution with OverlapCircle. Sorry ... And thanks again

(+1)

You are just moving too fast.

try with: 

public float float speed = 0.1f

FixedUpdate(){

transform.position += Vector3.right * Time.fixedDeltaTime * speed;

}

(1 edit)

Thanks for your answer, I tried that but it didn't change anything saddly for the trigger at (23,0,0), with the trigger at (35,0,0) It can move as I said, but with this speed it s very very slow.

Maybe I should stop trying to understand what is wrong and try to make progress in my prototype with the (35,0,0) that works ..

(+1)

Also, if it have a child with a rigidbody, but you are moving the child through the parent, make sure to tick the "IsKinematic" in the rigidbody.

(2 edits)

Could you explain to me why it is needed ?
I tried to do that but it didnt change the fact that it stopped with the first pos, and continue until the trigger with seconde pos.

The thing is I m thinking I might need the rigidbody later, and the reason I m using the parent is that I want to add more child later, so instead of moving every rigidbody at the same speed I was thinking it d be more convenient to move them via the parent.

That being said, my childs are contained in a list and change their position in the parent depending on their order. Maybe when the parent get the rigidbody as a child and the child adjust his position it does some weird movement, I m going to look into that before giving up and pretending there s no problem, using the 35 pos instead.

Yeah ... Solved ... I had a way to work around my problem but I still kept at trying to understand what was going wrong during almost 3 hours . Ok this is not great to progress in your dev, but it s still a good thing to do in general you may say. Yes. Of course . BUT . See what I added after 3 hours of trying everything but that..

That s right, maybe it could be interesting to know what object was causing the problem .. The rigidbody? The empty gameObject??

Oh Yeah right , there s this enemy that I keep Ignoring wich can trigger the boxCollider. Nice Work! 

Haha anyway thanks for everyone who took the time to answer me, I wish you a good jam and I hope I ll have something done at the end.

It doesn't solve the problem in my previous project but that s not exactly what I should focus on rn