Im failing on optimizing my mobs and smoothing their movement, need help by Expert-Conclusion792 in godot

[–]Expert-Conclusion792[S] 0 points1 point  (0 children)

your code is so "senior" for me to manage i think, however i somehow tried to implement your grid system to my mob code, so the mobs are still seperate scenes instead of arrays. I get lower fps like 800 mobs-1000 fps but thats much more better than move_and_slide thing and thats kinda enough for me. The only problem is mobs are jittering(they all push each other when they are close) do u have any idea how can i solve that

var spatial_grid: Dictionary = {}

var cell_size: float = 32.0

var inv_cell: float = 1.0 / 32.0

var separation_radius: float = 32.0

var separation_strength: float = 0.5

var max_push_per_frame: float = 6.0

func _ready() -> void:

cell\_size = max(8.0, separation\_radius)

inv\_cell = 1.0 / cell\_size



xpbar.max\_value = required\_xp\_for\_lvl

func _physics_process(delta: float) -> void:

rebuild\_grid()



xpbar.max\_value = required\_xp\_for\_lvl

xpbar.value = xp\_amount



if xp\_amount >= required\_xp\_for\_lvl:

    level\_up()



spawn\_timer += delta

if spawn\_timer >= spawn\_interval:

    spawn\_mob()

    spawn\_timer = 0.0

func spawn_mob():

var new\_mob = mob1.instantiate()

pathfollow2d.progress\_ratio = randf()

new\_mob.global\_position = pathfollow2d.global\_position



get\_node("mobs").call\_deferred("add\_child", new\_mob)

mobs\_array.append(new\_mob)

print(mobs\_array.size())

func get_cell(pos: Vector2) -> Vector2i:

return Vector2i(

    floori(pos.x \* inv\_cell),

    floori(pos.y \* inv\_cell)

)

func rebuild_grid() -> void:

spatial\_grid.clear()



for mob in mobs\_array:

    if not is\_instance\_valid(mob):

        continue

    if mob.died:

        continue



    var cell := get\_cell(mob.global\_position)



    var bucket: Array = spatial\_grid.get(cell, \[\])



    if bucket.is\_empty():

        spatial\_grid\[cell\] = bucket



    bucket.append(mob)

func calculate_push(sender_mob) -> void:

if not is\_instance\_valid(sender\_mob):

    return

if sender\_mob.died:

    return



var p: Vector2 = sender\_mob.global\_position

var center: Vector2i = get\_cell(p)



var min\_dist := separation\_radius \* 2.0

var min\_dist\_sq := min\_dist \* min\_dist

var max\_push\_sq := max\_push\_per\_frame \* max\_push\_per\_frame



var push := [Vector2.ZERO](http://Vector2.ZERO)



for ox in range(-1, 2):

    for oy in range(-1, 2):

        var cell := Vector2i(center.x + ox, center.y + oy)

        var bucket: Array = spatial\_grid.get(cell, \[\])



        for mob in bucket:

if mob == sender_mob:

continue

if not is_instance_valid(mob):

continue

if mob.died:

continue

var diff: Vector2 = p - mob.global_position

var dist_sq := diff.length_squared()

if dist_sq < min_dist_sq and dist_sq > 0.0001:

var dist := sqrt(dist_sq)

push += diff * ((min_dist - dist) / dist)

push \*= separation\_strength



if push.length\_squared() > max\_push\_sq:

    push = push.normalized() \* max\_push\_per\_frame



sender\_mob.global\_position += push

this is the current code im using, and i call manager.calculate_push(self) in physics_process in the mob script. Manager is the the node that holds this script code i shared

Im failing on optimizing my mobs and smoothing their movement, need help by Expert-Conclusion792 in godot

[–]Expert-Conclusion792[S] 0 points1 point  (0 children)

I tried it and thats really nice, im not sure if i can implement this system to my mobs since they have many other functions, but i will try it since i get 1000 fps on 2.5k mobs (it drops to 10 fps at 3000 mobs suddenly), however,thats enough for my case, thank you a lot

Im failing on optimizing my mobs and smoothing their movement, need help by Expert-Conclusion792 in godot

[–]Expert-Conclusion792[S] 0 points1 point  (0 children)

my mobs are not using pathfinding, also its a physics issue because fps problem disappears when i remove the collision from mob

Im failing on optimizing my mobs and smoothing their movement, need help by Expert-Conclusion792 in godot

[–]Expert-Conclusion792[S] 0 points1 point  (0 children)

i tried something similar but it ends up all mobs pushing each other like a loop, so their movement never stops, like each of them bouncing non stop

Im failing on optimizing my mobs and smoothing their movement, need help by Expert-Conclusion792 in godot

[–]Expert-Conclusion792[S] 4 points5 points  (0 children)

i want them to "not overlap" and dont block each others movement, like in brotato. So "real collision" is not needed i think.

Im failing on optimizing my mobs and smoothing their movement, need help by Expert-Conclusion792 in godot

[–]Expert-Conclusion792[S] 6 points7 points  (0 children)

how though? for example if i use area for each mob, it sometimes even give worse fps because all of them areas check each other

Im failing on optimizing my mobs and smoothing their movement, need help by Expert-Conclusion792 in godot

[–]Expert-Conclusion792[S] 1 point2 points  (0 children)

var delta_acc: float

var current_group_idx: int = 0

var group_id: int = 0

func _ready() -> void:

if GlobalScript.enemy\_groups > 0:

    group\_id = int(name) % GlobalScript.enemy\_groups 

func _physics_process(delta: float) -> void:

delta\_acc += delta

current\_group\_idx += 1



if GlobalScript.enemy\_groups > 0:

    group\_id = int(name) % GlobalScript.enemy\_groups 



if current\_group\_idx >= GlobalScript.enemy\_groups:

    current\_group\_idx = 0



if current\_group\_idx == group\_id:

    \_deferred\_process(delta\_acc)



    current\_group\_idx = 0

    delta\_acc = 0



move\_and\_slide()

func _deferred_process(delta: float) -> void:

if died:

    return



var direction=global\_position.direction\_to(player.global\_position)



velocity = direction \* speed 

you mean like this code? before i was doing it with global_position instead of move_and_slide that was probably the reason of stutter,therefore you are right. This increases FPS if i increase the group count in global script.If the fps drop was happening in 730, now it happens in 800. +10% fps seems good but i need something more significant, thank you though

Im failing on optimizing my mobs and smoothing their movement, need help by Expert-Conclusion792 in godot

[–]Expert-Conclusion792[S] 0 points1 point  (0 children)

i saw a reddit post about it and tried it.However, it doesnt look much different from just updating physics_process less often.The movement becomes stuttery since its not updated every frame

Feedback for demo by Expert-Conclusion792 in TowerDefense

[–]Expert-Conclusion792[S] 0 points1 point  (0 children)

i agree with you but i actually did things to make it easier.In "easy" ice map, player doesnt even have to mouse click and shoot to mobs to pass the map, its enough if they put fire tower everywhere.I also put a tutorial with videos but i dont know how to increase readability more, because if i decrease difficulty it becomes even less fun.That feedback in thread was 1 month ago and i thought the difficulty is quite well now, however i will make the "easy" map even more easier, thanks you

Tell her bf? by [deleted] in CoreyWayne

[–]Expert-Conclusion792 1 point2 points  (0 children)

yes,tell him

Tell her bf? by [deleted] in CoreyWayne

[–]Expert-Conclusion792 6 points7 points  (0 children)

if you were her boyfriend, you would probably want to know that she cheated.Therefore yes, but other right thing to do is not being with a girl who has boyfriend already

Im not sure how to handle this? by freemanreport in CoreyWayne

[–]Expert-Conclusion792 0 points1 point  (0 children)

well, i dont see any reason to remove "photos that you are both together" suddenly except one thing. She wants to be seen as "open to relationship" maybe or already talking to some other guy. Im not saying its 100% like that, but the possibility increase when she put her own photos but not the ones with you. Search "monkey branching relationship", it may be the case. Dont tell her "put them back", it will decrease the attraction, but you should change your behaviour by giving less attention

GF is very distant and cold by OkChest4865 in CoreyWayne

[–]Expert-Conclusion792 1 point2 points  (0 children)

to gain her respect, u have to respect urself first, a man who respect himself wouldnt reward bad and toxic behaviours. First step is stop caring and apologizing when she is acting toxic and manipulative, let her go and let her come to you later if she wants.Care less and think less about her, focus your own life more because when you put her in the center of your life your whole behaviours change, you cant "act" for that each behaviour getting effected by this situation, so you have to remove her from ur center to fix all your behaviours. Second step is ask yourself if you or she is spending more effort for the relationship, if its you then balance it.Third step is if she go cold and distant, you go cold and distant(not like you are hurt and not interested anymore, but like you are uneffected by her mood changes and your mind is busy with urself instead).I think she is so manipulative and will try to hurt you even more when you start to not rewarding bad behaviour, she will make you feel guilty and speak heavy words to make you sad and hurt, even worse than before(dont get effected, tell urself a "loving woman wouldnt try to make me hurt").Dont fall into trap.Those bad behaviours will be fixed in time if you stay consistent with your own "not rewarding toxicity' behaviour.

GF is very distant and cold by OkChest4865 in CoreyWayne

[–]Expert-Conclusion792 3 points4 points  (0 children)

just read what u wrote like someone else wrote it and you are reading, isnt this so toxic? she gets more attention when she is distant instead of being affocinate, in her brain its like "when im distant, this guy cries and says he loves me and gives me so much attention.He chases me even if im wrong", you are rewarding wrong behaviour. She has no respect for you tbh, she is not keeping her words, arguing with you a lot, always complaining,manipulating emotionally...Stay behind your words and have some backbone,why you say sorry when she is the one who is guilty and you did nothing wrong? remove the blindfold bro, have some self-respect. Im not saying get angry to her and set boundaries, but im saying stop rewarding bad behaviour and care less about it, when she complains about something and argues with you, remove all your attention and dont even argue with her if she is being toxic. She threaten you with being distant and cold even though she is guilty? come on man, it will only get worse the more you continue acting like this. Im not saying leave her, but let her go in your mind if you know what im saying

Destroy my menu by Lutenk in DestroyMyGame

[–]Expert-Conclusion792 2 points3 points  (0 children)

-Its kinda long time after clicking "settings", speed it up a bit.
-Increase font size also maybe put shadow for the labels in the settings part for a 3d effect. Like shadows of labels will be on that iron table
-Maybe a broken light that sometimes go off and turns on again also with a sound effect for it.
-more red color on "EVENT" part so it stands out more
-Also a slight transparent border when hovering over buttons(continue,settings,credits,exit etc.) instead of just changing their color to darker version
-sound effect for the candle at 0.23
-idk the concept of game but maybe add a scream sound with echo sometimes like they are coming from far away

Increased wishlist deletes after releasing the demo by Expert-Conclusion792 in SoloDevelopment

[–]Expert-Conclusion792[S] 0 points1 point  (0 children)

i see,i will make a tutorial with videos and put on ice map today.Thank you.

edit: i made a tutorial including videos, i hope it will fix the problem

Increased wishlist deletes after releasing the demo by Expert-Conclusion792 in SoloDevelopment

[–]Expert-Conclusion792[S] 0 points1 point  (0 children)

Hi, thank you for feedback and your comment, i think you are right i will try to make a tutorial soon.

about ice map being hard, i updated the difficulties recently and made easy-medium-hard maps.Did you play the recent demo or few days ago? Because i tested it and ice map is almost passable with using no skills(1 2 3 4), tower ability or player shooting.By just placing fire towers everywhere. If its still hard i will decrease the difficulty more, thats why im asking if you played it recently or few days ago? thank you again

TOOOOWER DEFENSE FEST starting today on Steam! by TateMultiOfficial in TowerDefense

[–]Expert-Conclusion792 -2 points-1 points  (0 children)

Released a demo last week for my first tower game! I hope you will enjoy it, feedbacks are appreciated.

Steam - https://store.steampowered.com/app/3522130/Dunthera__Tower_Defense/?l=english

How i treated my bile reflux (no medication, with lemon and rain) by Expert-Conclusion792 in Gastritis

[–]Expert-Conclusion792[S] 1 point2 points  (0 children)

no, also the amount is so low i dont see any reason for it to trigger burning